C语言中的问题
while(scanf("%d%d",&a,&b)!=EOF)while(scanf("%d%d",&a,&b)!=NULL)
有什么区别?
// Note:Your choice is C++ IDE #include <iostream> using namespace std; int main() { int a; while(scanf("%d",&a)!=EOF) //while(scanf("%d%d",&a,&b)!=NULL) { cout<<a<<endl; } return 0; }前者按crtl+z表示输入结束,这样键盘上单个字符的输入。后者只能人为地输入'\0'作为输入的结束