Title description
Xiao Suan attended his first computer introduction. The teacher said that the inside of the computer is composed of many small switches: 1 means on, 0 means off. So the smart little Suan understood that we usually use light switches to change 1 to 0 and 0 to 1!
Input format The
input is only one line, containing an integer of 0 or 1.
Output format If the
input is 0, 1 is output; if the
input is 1, 0 is output.
Sample Input
1
Sample Output
0
Ideas
Input 0 and output 1; input 1 and output 0.
C language code:
#include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
if(n == 0) printf("1");
else printf("0");
return 0;
}
C++ code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
n == 0 ? cout << "1" << endl : cout << "0" << endl;
return 0;
}