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

因为scanf 读入失败的时候返回值是 -1 直接拿来判断当然会死循环 另外 EOF == -1

Posted by yyii1111 at 2012-02-12 13:58:24 on Problem 1258
In Reply To:为什么用while(scanf("%d",&n))就TLE,而用while(scanf("%d",&n)!=EOF)就AC呢 Posted by:whu_zhengxinle at 2012-02-06 21:49:18
因为scanf 读入失败的时候返回值是 -1 直接拿来判断当然会死循环 另外 EOF == -1

一般是写成 while(~scanf(**)) 的形式的

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