Problem Description:
Sample input: O S
Sample output: I A
Code implementation:
1#include <stdio.h>2 3 Char*s ="' 1234567890-=qwertyuiop[]\\asdfghjkl; ' Zxcvbnm,./'";4 intMain ()5 {6 intc,i;7 while((c = GetChar ())! =EOF)8 {9 for(i =1; S[i] && s[i]!=c;i++);Ten if(S[i]) One { APutchar (s[i-1]); - } - Else the { - Putchar (c); - } - } + return 0; -}
Personal thoughts:
The input buffer is a row buffer. When you enter a string of characters from the keyboard and press ENTER, the characters inode are first sent to the input buffer for storage. Note that the only character that is returned is the first character of the input, which is the number one in the buffer. Then call GetChar () again, which will determine if there is data in the buffer, read the first character of the buffer if there is data, and then return. This goes down until the buffer is empty and waits for the input data. That's why input ABC will print ABC.
while ((c = GetChar ())! = EOF) (keyboard input problem)