Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language: how to compile the low-order four-digit inversion problem of short integers (both input and output are explained)
C language: how to compile the low-order four-digit inversion problem of short integers (both input and output are explained)
The topic must be in the early C environment, because the early int is 16bit, so the 8-bit data is called "short integer"; In the future, int will be 32bit, so in fact, the topic is to deal with a char type of data.

According to the explanation, this is not called "inversion", but should be called bit-by-bit inversion; Because "inversion" is to reverse the binary bit of 1234, that is, if it is11kloc-0/,it will become1kloc-0/1,and 00/should be output according to this problem.

Code text:

# contains "stdio.h"

int main(int argc,char *argv[]){

char ch

Printf ("Please enter a letter ... \ n");

if(scanf(" %c ",& ampch)== 1。 & amp(ch & gt= ' A ' & amp& ampch & lt= ' Z ' | | ch & gt= ' a ' & amp& ampch & lt='z '))

printf("0x%x\n",ch^0x0f);

other

Printf ("Input error, exit ... \ n");

Returns 0; ?

}