• uva10082 WERTYU


    题目信息

    Problem C:  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 punction symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

     

    Sample Input

     

    O S, GOMR YPFSU/
    

     

    Output for Sample Input

     

    I AM FINE TODAY.
    

     

     1 源代码:
    2
    3 #include<iostream>
    4
    5 #include<string>
    6
    7 using namespace std;
    8
    9 string str1="`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
    10
    11 string str2;
    12
    13 char a[128];
    14
    15
    16
    17 void Init()
    18
    19 {//建立按键的映射,有一点是:可以推出实际字符串中不会包括每行按钮的最后一个按钮
    20
    21 //如=,\,'或/
    22
    23 for(int i=1;i<str1.length();++i)
    24
    25 {
    26
    27 a[str1[i]]=str1[i-1];
    28
    29 }
    30
    31 a[' ']=' ';
    32
    33 }
    34
    35 int main()
    36
    37 {
    38
    39 Init();
    40
    41 while(getline(cin,str2))
    42
    43 {
    44
    45 for(int i=0;i<str2.length();++i)
    46
    47 {
    48
    49 cout<<a[str2[i]];
    50
    51 }
    52
    53 cout<<endl;
    54
    55 }
    56
    57 //system("pause");
    58
    59 return 0;
    60
    61 }

     

     

  • 相关阅读:
    python常用模块(3)
    python中的re模块
    python中的常用模块
    python中的模块及路径
    python中的文件操作(2)
    【weixin】微信支付简介
    【其他】博客园样式修改
    【weixin】微信企业号和公众号区别和关系是什么?
    【其他】./ 和../ 以及/区别
    【sdudy】ASCII,Unicode和UTF-8终于找到一个能完全搞清楚的文章了
  • 原文地址:https://www.cnblogs.com/redlight/p/2351388.html
Copyright © 2020-2023  润新知