Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:怎么还是不能停止,请再麻烦依次 (我解答了 嘻嘻)In Reply To:怎么还是不能停止,请再麻烦依次 Posted by:piaofushi919 at 2004-12-01 09:19:04 > #include <stdio.h> > #include <math.h> > void main(){ > float a,sum; > int n,c; > while (a!=0.00){ > scanf("%.2f",&a); > c=0; > sum=0; > for(n=2;n<67;n++){ > if(sum<a) > sum+=1/n; //错在这里 和我一样错 呵呵 //n要定义成float类型 //这样才能求出1/2=0.5 //因为计算结果类型是和计算数据类型一样,用int定义n 导致 1/2始终=0 > c=c+1; > if(sum>a) > break; > } > printf("%d card(s)\n",c); > } > } > > 有一个 WARNING Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator