#include<iostream>
using namespace std;
int main(){
int n;
int t=~scanf("%d",&n);
cout<<t<<endl;
return 0;
}
文件结束标志EOF的值为-1,所以读入结束时scanf的返回值为-1,而-1的取反为0(补码)。
故我们用while(~scanf("%d",&n))来结束读入。
手动输入ctrl+z,即代表输入EOF。
#include<iostream>
using namespace std;
int main(){
int n;
int t=~scanf("%d",&n);
cout<<t<<endl;
return 0;
}
文件结束标志EOF的值为-1,所以读入结束时scanf的返回值为-1,而-1的取反为0(补码)。
故我们用while(~scanf("%d",&n))来结束读入。
手动输入ctrl+z,即代表输入EOF。