原题
源码
//可以使用数组
#include<stdio.h>
int main()
{
float surplus[12];
float Avg_Surplus,sum=0.0;
// surplus为结余,AvgSurplus为平均结余
for(int i=0; i<12; i++){
scanf("%f",&surplus[i]);
sum = sum + surplus[i];
}
Avg_Surplus = sum / 12;
printf("$%.2f",Avg_Surplus);
return 0;
}
//不使用数组
#include<stdio.h>
int main()
{
float surplus;
float Avg_Surplus,sum=0.0;
// surplus为结余,AvgSurplus为平均结余
for(int i=0; i<12; i++){
scanf("%f",&surplus);
sum = sum + surplus;
}
Avg_Surplus = sum / 12;
printf("$%.2f",Avg_Surplus);
return 0;
}