习题7-4 求矩阵各行元素之和
1 #include<stdio.h> 2 3 int main(void) 4 { 5 int m, n; 6 int a[6][6]; 7 8 scanf_s("%d %d", &m, &n); 9 10 for (int i = 0; i < m; i++) 11 { 12 for (int j = 0; j < n; j++) 13 { 14 scanf_s("%d", &a[i][j]); 15 } 16 } 17 18 for (int i = 0; i < m; i++) 19 { 20 int sum = 0; 21 for (int j = 0; j < n; j++) 22 { 23 sum=sum+a[i][j]; 24 } 25 printf("%d\n", sum); 26 } 27 28 return 0; 29 }