-
Notifications
You must be signed in to change notification settings - Fork 0
/
trans.c
66 lines (49 loc) · 984 Bytes
/
trans.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_COLUMNAS 5
int tr(int M[][MAX_COLUMNAS] , size_t filas, size_t columnas);
int main(void)
{
int M[2][2]={
{1,2},
{4,5}
},j,i;
tr(M , 2,2);
for (i=0; i<2;i++){
for (j=0; j<2 ;j++){
printf(" %i ",M[i][j] );
}
puts("\n");
}
return 0;
}
int tr(int M[][MAX_COLUMNAS] , size_t filas, size_t columnas){
/*int M_transpuesta[columnas][filas];*/
int G,i,j;
G=0;
for (i=0; i<2;i++){
for (j=0; j<2 ;j++){
printf(" %i ",M[i][j] );
}
puts("\n");
}
for (i = 0; i < columnas; i++){
for (j=0; j <filas; j++){
G = M[i][j];printf("%i", M[i][j] );
printf(" %i\n", M[j][i] );
M[i][j] = M[j][i];
printf(" %i\n", M[i][j] );
M[j][i] = G;printf(" %i\n", M[j][i] );
/*M_transpuesta[j][i] = M[i][j];
printf("%i\n", M_transpuesta[j][i] );*/
}
}
for (i=0; i<2;i++){
for (j=0; j<2 ;j++){
printf(" %i ",M[i][j] );
}
puts("\n");
}
return 0;
}