5 like 5 dislike
One day, Batman got dead drink.
He sent a message to Superman.
However, it is wrong!!
Please help Superman to get the correct message.

For the given message, print a line containing the decoded words. However, it is not so hard task to replace each letter or punctuation symbol by the two immediately to its right alphabet on your standard keyboard!!

有一天
蝙蝠俠喝ㄎㄧㄤ了,
他傳了一個訊息給超人,
不料每個字都往左打歪了兩個鍵盤上的鍵(例如e打成q),
請你幫幫超人,解開蝙蝠俠想對他說的話。

---06/02 Update---

In this question, when you encounter "space",  just print "space";

when you encounter "Tab",  it is "q" or " w",  just print "w";

when your word becomes capital letter,  it means Batman might enter "a" or " s",  just print "s";

when your word encounter "Shift",  it won't show any words, so we don't know.

 

在這個例題中,

當你遇到"Space"時,直接印出"Space"即可;

當你遇到"Tab"的時候,有可能是"q"也有可能是"w"此時皆輸出"w";

當字變成大寫,代表蝙蝠俠輸入了"a"或是"s",此時皆輸出"s";

當蝙蝠俠輸入"Shift"的時候,不會有任何東西輸入,所以程式也無從判斷。

*New example

input:y     VE EU Qe V iijqm

(press keyboard)"y"," ","Tab","Caps Lock","v","e"," ","e","u"," ","q","Caps Lock","e"," ","Caps Lock","v"," ","Caps Lock","i","i","j","q","m"

output:i wsnt to est sn spple.

---example---

Input:

fyn hqvem

au rut jyhq eu sjrm

y auvle jyhqm

Output:

hi, kent.

do you like to fly.

i don't like.
asked in Introduction to Computer Programming (II) by (16 points)
edited by | 34 views
1 0
Great!
0 0
If he want to say "qaz",how about the input?
0 0
When Batman typed "qaz", his fingers wouldn't touch the keyboard.
So Superman wouldn't get the message which had "qaz" in the sentences. LOL
0 0
I think the rule here is not clear enough.  It'd be better if we can get more example input/output
1 0
when you encounter a space, just print the same space. Also notice that in the example output, it has some symbols such as ,.'  , be sure to include them in your code.
0 0
I update the question~
Thanks for your comment!!

4 Answers

1 like 0 dislike
Hidden content!
#include ** *** * *** *

#include * * ** *** *

using namespace std;

int main()

{
*** ****** * ** ** * * z;
** *** *** * * ** * * *** * decode;
* ** **** ***** ** i,j,k,x;
* ** * *** * * * ** tab[3][13];
* * **** * ** * ** ****** = 'q'; tab[0][1] = 'w'; tab[0][2] = 'e'; tab[0][3] = 'r'; tab[0][4] = 't'; tab[0][5] = 'y'; tab[0][6] = 'u'; tab[0][7] = 'i';
** ***** ** * * = 'o'; tab[0][9] = 'p'; tab[0][10] = '['; tab[0][11] = ']'; tab[0][12] = '\\';
* *** * **** *** * * ***
** ** *** * * * * * *** ** = 'a'; tab[1][1] = 's'; tab[1][2] = 'd'; tab[1][3] = 'f'; tab[1][4] = 'g'; tab[1][5] = 'h'; tab[1][6] = 'j'; tab[1][7] = 'k';
** ** * * * * *** * * = 'l'; tab[1][9] = ';'; tab[1][10] = '\'';
* ** **** * * *
* * ** ** * * ** * **
** ** **** * * ** ** *** = 'z'; tab[2][01] = 'x'; tab[2][02] = 'c'; tab[2][03] = 'v'; tab[2][04] = 'b'; tab[2][05] = 'n'; tab[2][06] = 'm'; tab[2][07] = ',';
* * * * * * = '.'; tab[2][9] = '/';
* * ** ** ** ***
* * * * * ** * * *
* **** * * ** ** * *** * *
* * * * * * * ** * = z.length();
** * * ** ** * * * * ** k<x; k++){
* **** * * * ****** *** * ***** ** ** * * ** ** * ** * * **
* *** ** ****** ** **** * **** * * ** * *** * * * * ** * ** * * * +='s';
* *** **** **** * **** * **** * * ** * *
* *** * * ** * *** ***** ** *** * * * ** if(z[k] == 9)
* * ** ** * ***** * * * * * * * * * ** * ** * * *** *** **
** **** * * *** * * * * * ** * * * * * if(z[k] == ' ')
* ** * ** * * * *** ** * * ****** ** * * *** ** * ** *** ** ' ';
** * **** * ** ** *** *** ** **** * * ****** * * if(z[k] == 14 || * ** == 15)
** * * *** ** ** * ** *** *** *** ** ****** ** ** * * * * ** * *
* **** **** ** ** * ******** *** * ***
* ** ** *** * * * ***** ** * ** ********* *** * ***
** * * * ** ** * * * * * * * ** ** ** ** *** * ** * ** * ***
**** * * * ** ** *** * ** *** * * * ** * * * *** * * * * * * *** ** **** * **** ** *** j++)
* * ** ** ** *** * *** *** * * * ***** *** ** ***** * ***** ** * ***** * *** * * * * * * * * * * *** * ***** ***** == tab[i][j])
** ***** * ** * ** ** *** ** ** * * ** * ** * * * ** * * ** * ** * *** *** *** * *** * ** * * ****** ** * ** * ** ** * *** *** * ** **** *
** **** *** ** * ** * * * *** ***** * * *
* * * * ***** * *********
* * * *** ** **** *
* * ** * * ********* ** * * *** * * ** ** **
* ** *** * ** ** ** * * 0;

}
answered by (1.4k points)
0 like 0 dislike
Hidden content!
#include * ** * *

#include * * ** ** * *

using namespace std;

int main()

{
* *** * * * * * ** * * z;
** * ** * ** ** * * ** decode;
* * * * * *** ** * ** i,j,k,x;
* ** ** * * * * ** *** * * *
* * * *** ** *** * ****** * = 'q'; tab[0][1] = 'w'; tab[0][2] = 'e'; tab[0][3] = 'r'; tab[0][4] = 't'; tab[0][5] = 'y'; tab[0][6] = 'u'; tab[0][7] = 'i';
**** *** ** * ** * * ** * ** = 'o'; tab[0][9] = 'p'; tab[0][10] = '['; tab[0][11] = ']'; tab[0][12] = '\\';
** * * ** **** * * ** **
* **** ***** * ***** = 'a'; tab[1][1] = 's'; tab[1][2] = 'd'; tab[1][3] = 'f'; tab[1][4] = 'g'; tab[1][5] = 'h'; tab[1][6] = 'j'; tab[1][7] = 'k';
*** ** ** * * *** ** ** * * = 'l'; tab[1][9] = ';'; tab[1][10] = '\'';
* ** **** * * ****** ****
* * * * * ***** * **
** * * **** **** ** ***** = 'z'; tab[2][01] = 'x'; tab[2][02] = 'c'; tab[2][03] = 'v'; tab[2][04] = 'b'; tab[2][05] = 'n'; tab[2][06] = 'm'; tab[2][07] = ',';
**** * ** * *** * *** * * = '.'; tab[2][9] = '/';
* * * * * ** * * * *
** *** * * * ** *
* ** ** * ** * * *** * ** * ** *
* * ** ** ** * ** = * * *
* ** *** * * *** ** *** ** k++){
** ** ** ** * ***** * *** **** **** *** * * **** * ** ** ** ** * * ** *** ** ***
* ** ** *** *** * * * ** * ** * * **** * *** * ** * * ** * ** *** * +='s';
* ** * * * * * **** **** * * * ** ** *
** * **** * * * * * ***** **** * ***** * if(z[k] == 9)
** ** ** * * * ** * * * * * ** ** ** * **** * * * *** * ** * *** ** ** ** *
* * * *** * * * * ** * ** *** * * ** * ** * if(z[k] == ' ')
*** ** ** *** ** ** **** ** * * * ** ** * ** *** ** *** * * * ' ';
** * * * * *** * *** *** ***** **** *** * ** * *
*** *** ** * *** * * *** ** ** ** * **** ***** ***
* **** ********** * *** * * * ** ** ** ** * ** * * ** ********* * * * ** * ** *
** * * * * *** ** *** * **** * ***** * *** * * * *** ** *** *** **** * * ***** ** * **** * j++)
* *** * ** **** ** * ** ***** ** * * * **** ** ** **** * * ** * ** *** * * * ** * * * * **** * ** *** * *** == tab[i][j])
* ***** ** ** * * **** ** ** *** * ** *** * * * *** * **** * * * ** * * * *** ****** ** ** * **** * * * * *** * ** ** * ** ** *
** ** * ** * ** * *** ** * ** *******
* *** ** * ** ** *****
** * *** * * *****
** **** * * ** * *** ** * ** * * ***** * * *
* **** ** ******* * *** * 0;

}
answered by (1.4k points)
1 like 0 dislike
Hidden content!
#include <iostream>

using namespace std;



char key_map[] = * * * *** * ** *** *** * * *



int main()

{

    char ch;

    while (cin.get(ch))

    {
* * ** ** * ** * **** * * * * *** ** (size_t i = 0; i != sizeof(key_map) - 2; ++i)
* * **** * ***** ** * * **** ** * ** * ** **
****** ** ****** ** * *** * ** *** ** ** * * * * * ** (ch == ' ')
** ***** * ** * ** * * **** * *** * ** ** * * ** ** * **
** ***** ** *** ** **** ** ** ** *** **** * *** * * * ** * * *** * ** * * * ** ** *** << ' ';
** ** * ********* ** * * * ***** ** *** ** *** ** **** * **** *** **** *** ** * *** **
** ** * * * * * ** * * * * *** ** * * ***** *** ** ** ** * * *****
* * ** ** *** ** * ** * * * *** * * ** **** *** ** * *** **** ** *** * if (key_map[i] == ch)
*** ** * * * ** ** * ** * ** ** * ** * ** *** *** ** *** * ** * ***** *
* *** * * *** ** * **** * * ** ** * * ** ** * * ** **** * * ** * * * + 2]);
***** ** * ** **** ** * ** * * * **** * ** * * ** * * **** * *** * ** * * *** *** * * * **** * * *
*** * * ** * * ** *** ** * * * ******** ** * * *** * * * ** *** *
* ** * *** ** *** *** * ** * ** *** ** * **

    }
* * * * * * *** *** ***** **** 0;

}
answered by (96 points)
1 like 0 dislike
Hidden content!
#include<iostream>

#include<string>

using namespace std;

int main()

{

    int i;

    char *** *** * * * ** * * * ** **
* *** ********* ** *** ** ** * **
* * * **** ** ** * * * * ***
* ** * ** **** * **** s;


* ** * ** ** ** * * ** * **

    {
** **** * * ** * ** *** ** * ***** *** * s[i]!='\0'; i++)
* ** *** * * * ** * * *** * * *** * * * *
** * ****** ** *** * * ****** * * *** * * * **** * *** **** * ** * ** ** * * ** *** && s[i]<='z')
* * * * ** * ** *** * * * *** ** ** * *** ** *** ** ** **** **** * * ** ***** ***** ** ****** * ** *
** **** ** ** ** * ** ** * * *** * * ** *** * * * ** ** ** * * * if(s[i]==' ')
* * ** **** * *** * * ****** * ***** ***** * * ** * *** * * ***** * * ** * * **** **** * ** * ** *** ** * *
** * * * ******* *** * ** **** * * * * **** * * * * * ** **** * if(s[i]==',')
*** * * * ** **** ** * * **** ** * *** *** **** * * * * * * * * * ** ** *** * * ** * * *** ** * *
* * ****** ****** *** ** ** * * *
* * **** * * ********* ** * ** ***** ** ****

    }


* * * * *** ** ** ** * * * * * 0;

}
answered by (-121 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.79.107
©2016-2018

Related questions

7 like 1 dislike
40 answers
2,966 questions
57,291 answers
28,945 comments
938 users