5个同学三门课程,求每门课程的平均成绩和总平均成绩
我是个C语言初学者,在用二维数组求平均值的时候遇到个奇怪问题。代码如下:程序代码:
#include "stdio.h" void main() { int i,j,ave=0,all_ave,v[2],a[3][5]; printf("please input the marks of five students:\n"); for(i=0;i<3;i++) { for(j=0;j<5;j++) { scanf("%d",&a[i][j]); ave+=a[i][j]; } v[i]=ave/5; ave=0; all_ave+=v[i]; } all_ave=(v[0]+v[1]+v[2])/3; printf("math=%d,c language=%d,Foxpro=%d",v[0],v[1],v[2]); printf("all average is:%d",all_ave); }在VC++下运行结果如下:
please input the marks of five students:
80 70 90 70 90
70 90 80 70 90
60 80 70 80 60
math=80,c language=80,Foxpro=100,all average is:100
望高手指点