| ||||||||||
| 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 | |||||||||
刚学C语言 小菜鸟的AC纪念。。。如有不足恳请指正#include<stdio.h>
int main()
{
double fun(int n);
double a[100],b[280];
int i,n,j;
for(i=0;;i++)
{
scanf("%lf",&a[i]);
if(a[i]==0.00)break;
}
n=i;
for(i=1;i<=279;i++)
b[i]=fun(i);
for(i=0;i<n;i++)
{
for(j=0;;j++)
if(b[j]>=a[i])break;
printf("%d card(s)\n",j);
}
//printf("%.3lf %.3lf",fun(276),fun(275));
return 0;
}
double fun(int n)
{
double i,sum=0;
for(i=2;i<=n+1;i++)
sum+=1.0/i;
return sum;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator