| ||||||||||
| 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 | |||||||||
这个代码如何改才能正确,跪请赐教?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator