题目:输入一个m*n整型的二维数组,对其每行求和,和单独存放在一个一维数组中。

2025-02-25 17:29:55
推荐回答(1个)
回答1:

#include
int main(){
int *a,*b;
int m,n,i,j;
printf("input m n:\n");
scanf("%d %d",&m,&n);
a = (int *)malloc(sizeof(int)*m*n);
b = (int *)malloc(sizeof(int)*m);
printf("input the array in row order:\n");
for (i=0;ifor (j=0;jb[j]=0;
for (i=0;i};
printf("==================\n");
for (j=0;jreturn 0;
}
例子:
input m n:
3 4
input the array in row order:
11 12 13 14
21 22 23 24
31 32 33 34
==================
50 90 130