#include <stdio.h>
int main()
{
int a[4][4], i, j;
printf("请输入数字\n");
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
scanf_s("%d", &a[i][j]);
int sum;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
sum += a[i][j];
printf("%d\n", sum);
}
参考一下吧
#include <stdio.h>
int main()
{
int a[4][4], i, j;
printf("请输入数字\n");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
scanf("%d", &a[i][j]);
}
int sum;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
sum += a[i][j];
}
printf("最终等于%d\n", sum);
return 0;
}