zoukankan      html  css  js  c++  java
  • 1093.WERTYU

    题目描述:

        A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.

    输入:

        Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.

    输出:

        You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

    样例输入:
    O S, GOMR YPFSU/
    样例输出:
    I AM FINE TODAY.
    #include<iostream>
    #include<cstring>
    #include<stdio.h>
    using namespace std;
    
    char translate(char x){
        switch(x)
        {
            case 'W': x='Q';break;
            case 'E': x='W';break;
            case 'R': x='E';break;
            case 'T': x='R';break;
            case 'Y': x='T';break;
            case 'U': x='Y';break;
            case 'I': x='U';break;
            case 'O': x='I';break;
            case 'P': x='O';break;
            case '[': x='P';break;
            case 'S': x='A';break;
            case 'D': x='S';break;
            case 'F': x='D';break;
            case 'G': x='F';break;
            case 'H': x='G';break;
            case 'J': x='H';break;
            case 'K': x='J';break;
            case 'L': x='K';break;
            case ';': x='L';break;
            case 'X': x='Z';break;
            case 'C': x='X';break;
            case 'V': x='C';break;
            case 'B': x='V';break;
            case 'N': x='B';break;
            case 'M': x='N';break;
            case ',': x='M';break;
            case '.': x=',';break;
            case '/': x='.';break; 
            case '\': x=']';break;         
        }
        return x;
    }
    
    int main(){
        char str[10000];
        char s[10000];
        while(gets(str)){
            int len=strlen(str);
            for(int i=0;i<len;i++)
            {
                if(str[i]==' ') s[i]=str[i];
                else {
                    s[i]=translate(str[i]);
                }
                cout<<s[i];
            }
            cout<<endl;
        }
        return 0;
    }
  • 相关阅读:
    关于串通京东接口的demo
    http链接中请求进行编码,Http请求api
    RabbitMQ 创建用户和创建Virtual host
    dedecms调用当前栏目的子栏目及子栏目文章
    dede调出所有栏目以及栏目下的二级栏目
    JS判断移动端访问设备并加载对应CSS样式
    border-style
    网页色阶表
    破解centos7 密码
    DEDECMS打开网站后台系统首页卡解决方法
  • 原文地址:https://www.cnblogs.com/bernieloveslife/p/9736462.html
Copyright © 2011-2022 走看看