#include<stdio.h>
#include<stdlib.h>
int main()
{
int x,y;
while((y=scanf("%d",&x))==1)
{
printf("%d\n",x);
printf("%d\n",y);
}
printf("%d\n",y);
system("pause");
}
输入2.6,为何输出 2 1 0 而不是 2 1 1
只读 ". " 么? ".6"读不读?
追答只读“.”,然后scanf 就出错了,无法再用它读进其他数据,除非fflush(stdin); 才可以。
“6 ”是读不到的,因为读到“.”之后已经退出了循环。