| ||||||||||
| 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 | |||||||||
请问各路神牛,POJ上用scanf读入double到底该用什么格式符?"%lf"失败了。我最后的解决方案是:...自己写一个读入double的函数(痛苦)
double readDouble(){
char c=getchar();
while ((c>'9' || c<'0') && c!='.')c=getchar();
double r=0.0;
if (c!='.'){
r=(double)(c-'0');
while (c=getchar(),'0'<=c && c<='9')
r=10.0*r+(double)(c-'0');
}
if (c=='.'){
double t=0.1;
while (c=getchar(),'0'<=c && c<='9')
r=r+t*(c-'0'),t=t*0.1;
}
return r;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator