程序1:#include <stdio.h>
int main()
{
int i, j, s = 0, average, v[3], a[3][5];
printf("input score\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 5; j++)
{
scanf("%d", &a[i][j]);
s = s + a[i][j];
}
v[i] = s / 5;
s = 0;
}
average = (v[0] + v[1] + v[2]) / 3;
printf("math:%d\nc language:%d\ndbase:%d\n", v[0], v[1], v[2]);
printf("total:%d\n", average);
return 0;
}
输出框:
input score
1 2 3 4 5
3 4 5 6 7
5 2 2 0 1
math:3
c language:5
dbase:2
total:3
请按任意键继续……
程序二:#include <stdio.h>
int main()
{
int i, j, s = 0, average, v[3], a[5][3];
printf("input score\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 5; j++)
{
scanf("%d", &a[j][i]);
s = s + a[j][i];
}
v[i] = s / 5;
s = 0;
}
average = (v[0] + v[1] + v[2]) / 3;
printf("math:%d\nc language:%d\ndbase:%d\n", v[0], v[1], v[2]);
printf("total:%d\n", average);
return 0;
}
输出框:
input score
1 2 3 4 5
3 4 5 6 7
5 2 2 0 1
math:3
c language:5
dbase:2
total:3
请按任意键继续……