-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatrix.c
51 lines (38 loc) · 915 Bytes
/
matrix.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
//n*m matrix
#include <stdio.h>
int main(){
int n, m;
int a[100][100];
scanf("%d%d", &n, &m);//input no of row i&j column
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
scanf("%d", &a[i][j]);//input
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
printf("%d\t", a[i][j]);//output
}
printf("\n");//print next row in new line
}
return 0;
}
//n*n matrix
#include <stdio.h>
int main(){
int n;
int a[100][100];
scanf("%d", &n);//input no of row i&j column
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
scanf("%d", &a[i][j]);//input
}
}
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
printf("%d\t", a[i][j]);//output
}
printf("\n");//print next row in new line
}
return 0;
}