c语言问题,求高手解答!!
#include<stdio.h>#defineSUM100000intmain(){floatamount,aver,total;inti;for(i=1,total=...
#include<stdio.h>
#define SUM 100000
int main( )
{
float amount, aver, total;
int i;
for(i = 1, total = 0; i<=1000; i++)
printf("please enter amount:\t");
scanf("%f", &amount);
total = total + amount;
if(total>=SUM)break;
aver = total/i;
printf("num = %d\naver = %10.2f\n", i, aver);
return 0;
} 展开
#define SUM 100000
int main( )
{
float amount, aver, total;
int i;
for(i = 1, total = 0; i<=1000; i++)
printf("please enter amount:\t");
scanf("%f", &amount);
total = total + amount;
if(total>=SUM)break;
aver = total/i;
printf("num = %d\naver = %10.2f\n", i, aver);
return 0;
} 展开
5个回答
展开全部
#include<stdio.h>
#define SUM 100000
int main()
{
float amount,aver,total;
int i;
for(i = 1, total = 0; i<=1000; i++)
{
printf("please enter amount:\t");
scanf("%f", &amount);
total = total + amount;
if(total>=SUM)
{
break;
}
}
aver = total/i;
printf("num = %d\naver = %10.2f\n", i, aver);
return 0;
}
#define SUM 100000
int main()
{
float amount,aver,total;
int i;
for(i = 1, total = 0; i<=1000; i++)
{
printf("please enter amount:\t");
scanf("%f", &amount);
total = total + amount;
if(total>=SUM)
{
break;
}
}
aver = total/i;
printf("num = %d\naver = %10.2f\n", i, aver);
return 0;
}
展开全部
你的for 循环 没有{} 加一个{} 就可以了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
{前加printf(“please enter ”)
break后加}
break后加}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询