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

这个代码如何改才能正确,跪请赐教?

Posted by summery at 2006-03-30 14:51:40 on Problem 1131
#include<stdio.h>

void main()
{
	long double sum = 0.0,num=0.0;
	double k = 0.0;
	int  i= 1;
	int mod = 10;
	int base = 2<<2;

	while(scanf("%lf",&num))
	{
	while(num - int(num)>0.00000001)
	{
		num = num*10;
		k = int(num) %mod;
		sum += k/double(base);
		base=base<<3;
		
		k = 0.0;
	}
	printf("%.30lf\n",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