Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

刚学C语言 小菜鸟的AC纪念。。。如有不足恳请指正

Posted by KAYY at 2019-02-10 17:37:01 on Problem 1003
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator