摘要: 注意分析n,循环次数与n不一样,要减一#include<stdio.h>int main(){ float score,sum=0,average; int i,n; for(i=1;i<31;i++) { scanf("%f",&score); if(score<0) break; sum=sum+score; } n=i-1; average=sum/n; printf("%d\n%f\n",n,average); return 0;} 阅读全文
posted @ 2012-05-23 22:16 尔滨之夏 阅读(531) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ double p=1.30756e9,r=0.01; int y; for(y=2006;p<1.5e9;y++) { p=p*(1+r); } printf("%d\n%e\n",y-1,p); return 0;} 阅读全文
posted @ 2012-05-23 22:10 尔滨之夏 阅读(283) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){ float amount,sum=0; do{ scanf("%f",&amount); sum=sum+amount; }while(sum<10000); printf("%f\n",sum); return 0;} 阅读全文
posted @ 2012-05-23 21:11 尔滨之夏 阅读(212) 评论(0) 推荐(0) 编辑