HDU——1982Kaitou Kid - The Phantom Thief (1)(坑爹string题)
2016-02-24 12:54
429 查看
Kaitou Kid - The Phantom Thief (1)
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2694 Accepted Submission(s): 1182
[align=left]Problem Description[/align]
Do you know Kaitou Kid? In the legend, Kaitou Kid is a master of disguise, and can take on the voice and form of anyone. He is not an evil person, but he is on the wrong side of the law. He's the very elusive phantom thief who never
miss his prey although he always uses word puzzles to announce his targets before action.
You are the leader of a museum. Recently, you get several priceless jewels and plan to hold an exhibition. But at the moment, you receive Kid's word puzzle... Fortunately, It seems Kid doesn’t want to trouble you, and his puzzle is very easy. Just a few minutes,
You have found the way to solve the puzzle:
(1) change 1 to 'A', 2 TO 'B',..,26 TO 'Z'
(2) change '#' to a blank
(3) ignore the '-' symbol, it just used to separate the numbers in the puzzle
[align=left]Input[/align]
The first line of the input contains an integer C which means the number of test cases. Then C lines follow. Each line is a sentence of Kid’s word puzzle which is consisted of '0' ~ '9' , '-' and '#'. The length of each sentence is
no longer than 10000.
[align=left]Output[/align]
For each case, output the translated text.
[align=left]Sample Input[/align]
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
题目挺坑,多个#不能无视,多个-要视为1个-,WA+PE数次之后终于对了
#include<iostream> #include<string> #include<algorithm> #include<sstream> using namespace std; int main(void) { int n,num,i,j; string s,ans; while (cin>>n) { getchar(); while (n--) { getline(cin,s); ans=""; for(i=0; i<s.size(); i++) { if(s[i]=='-')//第一种为- continue; else if(isdigit(s[i]))//第二种为数字 { if(isdigit(s[i+1])) { ans=ans+char((s[i]-'0')*10+s[i+1]-'0'+64); i++;//既然已经判断过了I+1那循环就要从下下次开始,下同 } else if(s[i+1]=='-') { ans=ans+char(s[i]-'0'+64); i++; } else if(s[i+1]=='#') { ans=ans+char(s[i]-'0'+64); ans=ans+" "; i++; } else ans=ans+char(s[i]-'0'+64); } else if(s[i]=='#')//第三种为# { ans+=" "; } } cout<<ans<<endl; } } return 0; }
相关文章推荐
- zabbix proxy 服务器 netstat 出现大量Time_Wait连接问题
- 为什么delegate属性使用assign而不是retain?
- gmail巧用过滤器清空邮箱
- SMTP判断邮箱是否存在,检查email地…
- RAID相关知识简介
- Host key verification fail…
- 新浪免费企业邮箱Foxmail客户端设…
- Opencv— — Bias and Gain
- rndc: connect failed 解决
- Google Map,Baidu Map,latitude,longitude
- looking for domain authoritative name server and domain name location
- Leetcode 70 Climbing Stairs 递推
- IP address '172.172.200.88' could not be resolved: Temporary failure in name resolution
- DataInputStream类和RandomAccessFile类的使用方法
- (23)odoo中的domain表达式
- Async/Await - Best Practices in Asynchronous Programming z
- #define+do{} while(0)+peeror的思考
- 1106. Lowest Price in Supply Chain (25)
- 解决MyEclipe出现An error has occurred,See error log for more details的错误
- 解决MyEclipe出现An error has occurred,See error log for more details的错误