#include <stdio.h>int main(){ int a; int i; int sum=0; printf("How many number?:"); scanf("%d",&a); int num[a]; printf("input number:\n"); for(i=0;i<a;i++) { scanf("%d",&num[i]); sum+=num[i]; } printf("%d",sum); double average=(double)sum/a; printf("%d",a); if(a>=0) printf("the else is %f",average); }应该改成这样,你这个程序应该是输出平均数。for 循环中for(i=0;i<a;i )应该改成for(i=0;i<a;i++)b变量其实是没有必要的。直接写成sum+=num[i]; 即可然后double average=sum/a;这一句应该改成double average=(double)sum/a;因为左边是double ,右边结果是int,会造成精度降低最后输出的时候,average为double,你却输出为%d,这是int才这样写,应该改成%f