main() { float a[10]={1,2,3,5,4,6,7,8,9,11}; float sum,ave; int i;
for(i=0;i<10;i++) { sum=sum+a[i]; } printf("sum is:%f",sum); ave=sum/10; printf("vae is:%f",ave); }
main() { float a[10]={1,2,3,5,4,6,7,8,9,11}; float sum=0,ave; /*sum一定要初始化,否则系统给值将是随机的,但是ave没有必要*/ int i;