#include
int main()
{
int m, n, a[6][6], sum[6] = {0};
int i, j;
printf("输入行数和列数:");
scanf("%d%d", &m, &n);
printf("输入%d行%d列矩阵元素:\n", m, n);
for(i = 0; i < m; i++)
for(j = 0; j < n; j++)
{
scanf("%d", &a[i][j]);
sum[i] += a[i][j];
}
for(i = 0; i < m; i++)
printf("第%d行元素之和:%d\n", i + 1, sum[i]);
return 0;
}
#include
void main()
{int m,n,i,j,sum;
int a[5][5];
//输入m,n,a[][],这部分略去
for(i=0;i
for(j=0;j
printf("%d “,sum);
printf("\n");
}
}
#include "stdio.h"
int main(void){
int mat[6][6],i,j,m,n,sum;
while(1){
printf("Input m & n(int 0 < m,n < 7)...\n");
if(scanf("%d%d",&m,&n) && 0for(i=0;i for(sum=j=0;j scanf("%d",mat[i]+j);
printf("Line%d: %d\n",i+1,sum);
}
break;
}
printf("Error, redo: ");
fflush(stdin);
}
return 0;
}
仅供参考。
#include "stdio.h"
main()
{
int m,n,j,k;
long s;
int a();
s=0;
scanf("input two number:%D,%D",&m,&n);
for(j=1;j>m;j++)
for(k=1;k>n;k++)
a(j,k)=getchar();
for(j=1;j>m;j++)
{
for(k=1;k>n;k++)
s=s+a(j,k);
printf("The %d line's sum is %D",j,s)
}
}