| ||||||||||
| 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:谁能帮我改一下,把正确的贴出来,是C的。谢谢!In Reply To:谁能帮我改一下,把正确的贴出来,是C的。谢谢! Posted by:boss185 at 2006-12-20 14:38:27 可以的啊
这道题其实直接这样精度就可以了
> #include <stdio.h>
> #include <math.h>
>
> int main()
> {
> float c,sum,n;
>
> scanf ("%f",&c);
>
> while (fabs(c) < 0.001) {
> for (sum = 0,n = 1;sum < c;n++)
> sum += 1 / (n + 1);
> printf ("%d card(s)\n",(int)n-1);
> scanf ("%f",&c);
> }
>
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator