UVa 10222-Decode the Mad man

来源:互联网 发布:花瓣软件下载 编辑:程序博客网 时间:2024/06/11 17:20

就是美个字母错打了两位,输出该字母在键盘上的前两位。

#include <stdio.h>#include <string.h>#include <ctype.h>char *s = "qwertyuiop[]asdfghjkl;'zxcvbnm,.";int main (){    //freopen ( "input.txt", "r", stdin );    //freopen ( "output.txt", "w", stdout );    int i, c;    while ( ( c = getchar ()) != EOF ) {        //putchar ( c );        if ( isupper ( c ) ) c = tolower ( c );        for ( i = 1; s[i] && s[i] != c; ++i ) ;        if ( s[i] ) putchar ( s[i - 2] );        else putchar ( c );    }    return 0;}