题目连接:php
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1023ios
/* 题目大意是把输入错误的数据复原成正确的数据 输入的数据总会把输入的字符向右移动一个 因此咱们要将输入的字符向左移动一位 */ #include <iostream> #include <stdio.h> char s[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; using namespace std;//应为此处的要处理的数据比较多,因此我把他将全部的字符都存入一个字符串里 int main(void) { int i; char ch;//每次读入的字符 while ((ch = getchar()) != EOF) {//每次读取一个字符 for (i = 0; s[i] && s[i] != ch; i++);//找到字符串中相应位置 if (s[i])//若是在s中找到了这个字符,那就打印它的前一个字符 putchar(s[i - 1]); else//若是没有找到,那就输出当前读入的字符 putchar(ch); } return 0; }