Question S: decipher messages
Time limit: 1 Sec Memory Limit: 32 MB
submitted: 152 solved: 66
Title Description
Bob received a strange message, some of which are all symbols and numbers, but letters deciphering method given above, as follows:
- The 1 becomes 'A' , 2 becomes 'B' , ..., 26 is changed to 'the Z' ;
- The '#' into a space;
- Ignore '-' , the original letter '-' for dividing the digital only.
Now you please help Xiao Ming programming decipher this message.
Entry
A first act input integer C, represents the number of test data sets.
Next C lines of the input character string to be a deciphered string contains only numbers , '-' and '#' , the length does not exceed 100 .
Export
For each set of input, output decipher the text.
Sample input Copy
4 9#23-9-12-12#19-20-5-1-12#1-20#12-5-1-19-20#15-14-5#10-5-23-5-12 1-14-4#12-5-1-22-5#20-8-5#13-21-19-5-21-13#9-14#20#13-9-14-21-20-5-19 1-6-20-5-18#20-8-5#15-16-5-14-9-14-7#15-6#20-8-5#5-24-8-9-2-9-20-9-15-14 7-15-15-4#12-21-3-11
Sample output Copy
I WILL STEAL AT LEAST ONE JEWEL AND LEAVE THE MUSEUM IN T MINUTES AFTER THE OPENING OF THE EXHIBITION GOOD LUCK
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int T;
string s;
scanf("%d",&T);
getchar();
while(T--){
cin>>s;
for(int i = 0;i < s.size();i++){
if(s[i]=='#'){
cout<<" ";
}
if(s[i]=='-'){
continue;
}
if(s[i]>='0'&&s[i]<='9'){
int num=0;
if(s[i+1]>='0'&&s[i+1]<='9'){
num=10*(s[i]-'0')+(s[i+1]-'0');
i++;
}else{
num=s[i]-'0';
}
char ch='A'+num-1;
cout<<ch;
}
}
cout<<endl;
}
}
Code