Last active
February 12, 2019 12:12
-
-
Save thomwiggers/935d927f1b0fca71e38cc881db19f54d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
int i,j; | |
unsigned long long **m; | |
unsigned long long **mt; | |
while(1) | |
{ | |
// allocate matrix m | |
m = malloc(1000*sizeof(unsigned long long*)); | |
if(m == NULL) return -1; | |
for(i=0;i<1000;i++) | |
{ | |
m[i] = malloc(1000*sizeof(unsigned long long)); | |
if(m[i] == NULL) return -1; | |
} | |
// allocate matrix mt | |
mt = malloc(1000*sizeof(unsigned long long*)); | |
if(mt == NULL) return -1; | |
for(i=0;i<1000;i++) | |
{ | |
mt[i] = malloc(1000*sizeof(unsigned long long)); | |
if(mt[i] == NULL) return -1; | |
} | |
for(i=0;i<1000;i++) | |
for(j=0;j<1000;j++) | |
m[i][j] = 1000*i+j; | |
// transpose matrix m, write to mt | |
for(i=0;i<1000;i++) | |
for(j=0;j<1000;j++) | |
mt[i][j] = m[j][i]; | |
// free matrices m and mt | |
free(m); | |
free(mt); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment