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

istream不会主动判断eof的

Posted by frkstyc at 2006-06-03 19:33:05 on Problem 1207
In Reply To:请教:为什么while (!cin.eof())不行,而while (cin >> a >> b)就可以了(附源码)? Posted by:xbz at 2006-06-03 19:28:06
> 
> int main()
> {
> 	int a, b, temp, max;
> 	//while (!cin.eof()) {         //这样写提交是WA
> 	while (cin >> a >> b) {       //这样写提交就AC了,Why?
>         	cin >> a >> b;
> 		cout << a << " " << b << " ";
> 
> 		if (a > b) {
> 			temp = a;
> 			a = b;
> 			b = temp;
> 		}
> 
> 		max = 0;
> 		for (int i = a; i <= b; ++i) {
> 			int cur = get_cycle(i);
> 			if (cur > max)
> 				max = cur;
> 		}
> 		cout << max << endl;
> 	}
> 
> 	return 0;
> }

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