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

请问各路神牛,POJ上用scanf读入double到底该用什么格式符?"%lf"失败了。

Posted by fanhqme at 2010-07-27 10:47:44 on Problem 1810
我最后的解决方案是:...自己写一个读入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:
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