解法一:利用cin和cout
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int x;
cin >> x;
if(x==0)
cout << 1;
else //或if(x==1)
cout << 0;
return 0;
}
也可以先1后0
解法二:利用scanf和printf
#include <iostream>
using namespace std;
int main()
{
int x;
scanf("%d", &x);
if(x==0)
printf("%d", 1);
else //或if(x==1)
printf("%d", 0);
return 0;
}
也可以先1后0