| ||||||||||
| 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:hmh0512 at 2009-08-01 19:50:50 > #include <stdio.h>
> main()
> {
> long n,i;
> double a[100000];
> a[0]=0;
> for(i=1;i<100000;i++)
> a[i]+=a[i-1]+0.5/i;
> printf("Cards Overhang\n");
> while(scanf("%d",&n)!=EOF)
> printf("%5d %.3lf\n",n,a[n]);
> }
for(i=1;i<100000;i++)
a[i]+=a[i-1]+0.5/i;
你的程序解法本身有错误,i是以i+=2递增的,不是加1~~
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator