UVa 10082 - WERTYU

无语了我哈哈哈哈哈哈哈哈!! 看到这道题就想到了最笨的办法, 明明知道规范解法不是这样,还是闲的没事把所有情况都写了出来,而且这过程中还漏了一种情况,这是个教训啊!          要熟练用常量数组解决问题,简化代码!          多想!

#include <stdio.h>
#include <string.h>
int main()
{
    int i,n;
    char c;
    while( (c=getchar()) != EOF )
    {
        if(c=='1')
            c='`';
         else if(c=='2')
            c='1';
         else if(c=='3')
            c='2';
         else if(c=='4')
            c='3';
         else if(c=='5')
            c='4';
         else if(c=='6')
            c='5';
         else if(c=='7')
            c='6';
         else if(c=='8')
            c='7';
         else if(c=='9')
            c='8';
         else if(c=='0')
            c='9';
         else if(c=='-')
            c='0';
         else if(c=='=')
            c='-';
         else if(c=='W')
            c='Q';
         else if(c=='E')
            c='W';
         else if(c=='R')
            c='E';
         else if(c=='T')
            c='R';
         else if(c=='Y')
            c='T';
         else if(c=='U')
            c='Y';
         else if(c=='I')
            c='U';
         else if(c=='O')
            c='I';
         else if(c=='P')
            c='O';
         else if(c=='[')
            c='P';
         else if(c==']')
            c='[';
         else if(c==' \ ')
            c=']';
         else if(c=='S')
            c='A';
         else if(c=='D')
            c='S';
         else if(c=='F')
            c='D';
        else if(c=='G')
            c='F';
        else if(c=='H')
            c='G';
        else if(c=='J')
            c='H';
        else if(c=='K')
            c='J';
        else if(c=='L')
            c='K';
        else if(c==';')
            c='L';
        else if(c==39)
            c=';';
        else if(c=='X')
            c='Z';
        else if(c=='C')
            c='X';
        else if(c=='V')
            c='C';
        else if(c=='B')
            c='V';
        else if(c=='N')
            c='B';
        else if(c=='M')
            c='N';
        else if(c==',')
            c='M';
        else if(c=='.')
            c=',';
        else if(c=='/')
            c='.';
        printf("%c",c);
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值