-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransposeMatrix.c
59 lines (52 loc) · 1.15 KB
/
TransposeMatrix.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
#include <stdio.h>
#include <stdlib.h>
void main(){
int a,b,matrix[10][10],transpoze[10][10],i,j,x,y;/* a line, b column - i,j counter - x value assignment variable - y largest number variable*/
x=0;
y=0;
printf("Enter the dimensions of your matrix.\nnumber of rows? : ");
scanf("%d",&a);
printf("your column count? : ");
scanf("%d",&b);
printf("Now we will ask you to enter the row and column values, respectively.\n\n");
/*taking values*/
for(j=0;j<b;j++){
printf("%d. We start from the values of the line.\n",j+1);
for(i=0;i<a;i++){
printf("%d. value: ",i+1);
scanf("%d",&x);
matrix[i][j]=x;
}
}
printf("your matrix : \n");
/*printing matrix to screen*/
for(j=0;j<b;j++){
for(i=0;i<a;i++){
printf("%d ",matrix[i][j]);
}
printf("\n");
}
printf("Now let's transpose your matrix : \n");
/*matrix transpose calculation*/
for(i=0;i<a;i++){
for(j=0;j<b;j++){
transpoze[j][i]=matrix[i][j];
}
}
/*matrix transpose printing*/
for(i=0;i<a;i++){
for(j=0;j<b;j++){
printf("%d ",transpoze[j][i]);
}
printf("\n");
}
/* Finding the largest number in a matrix */
for(j=0;j<b;j++){
for(i=0;i<a;i++){
if(matrix[i][j]>y){
y=matrix[i][j];
}
}
}
printf("Your max number : %d",y);
}