| ||||||||||
| 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 | |||||||||
明白为什么了(里面有内容)In Reply To:单纯到达输入结束cin.eof()是不会返回true的,除非再有一次读入失败的操作 Posted by:frkstyc at 2006-06-04 12:17:19 while (!cin.eof()) {
cin >> a >> b;
我自己写的测试数据的最后一行是这样的:
900 1000
1000后面直接是EOF,
这样,读完1000后,
流的状态就变成EOF了,
于是可以用cin.eof()来判断。
而如果1000后面还有空白的话,
读完1000后状态不会变成EOF,
cin.eof()就没用了,
会再读一次,就出错了。
估计系统的测试数据的最后有空白。
呵呵,多谢了。:)
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator