while(scanf("%d%d",&a,&b)!

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 16:39:36

while(scanf("%d%d",&a,&b)!
while(scanf("%d%d",&a,&b)!

while(scanf("%d%d",&a,&b)!
EOF=end of file 这回你知道什么意思了吧
scanf函数的返回值说明.
Returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned.
If format is a NULL pointer, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions return EOF and set errno to EINVAL.
EOF就是-1,是在stdio.h里定义的.
按照上面的说明,scanf函数只有在第一个参数为NULL(空指针)的情况下,才可能返回EOF,否则,返回成功格式化并赋值的参数个数(>=0).
所以,楼主你的这个循环,将是一个死循环.