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

Problem Description
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

 
Input
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.
 
Output
For each case, output the translated text.
 
Sample Input
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;
}

HDU——1982Kaitou Kid - The Phantom Thief (1)(坑爹string题)的更多相关文章

  1. HDOJ/HDU 1982 Kaitou Kid - The Phantom Thief (1)(字符串处理)

    Problem Description Do you know Kaitou Kid? In the legend, Kaitou Kid is a master of disguise, and c ...

  2. HDU 1983 Kaitou Kid - The Phantom Thief (2)

    神题,搜索太差,来自网络的题解与程序 思路: 封锁出口或者入口周围的格子. 最多需要4个封锁点. 所以我们可以采取这样的策略: 1.寻找一条盗贼的可行路线,如果没有,返回0. 2.计算封锁出口和入口四 ...

  3. 【HDOJ】1983 Kaitou Kid - The Phantom Thief (2)

    不仅仅是DFS,还需要考虑可以走到终点.同时,需要进行预处理.至多封闭点数为起点和终点的非墙壁点的最小值. #include <iostream> #include <cstdio& ...

  4. hdu 5288||2015多校联合第一场1001题

    pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...

  5. 「题解」agc031_e Snuke the Phantom Thief

    本文将同步发布于: 洛谷博客: csdn: 博客园: 简书. 题目 题目链接:洛谷 AT4695.AtCoder agc031_e. 题意简述 在二维平面上,有 \(n\) 颗珠宝,第 \(i\) 颗 ...

  6. HDU 5120 Intersection(2014北京赛区现场赛I题 计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5120 解题报告:给你两个完全相同的圆环,要你求这两个圆环相交的部分面积是多少? 题意看了好久没懂.圆环 ...

  7. HDU 5073 Galaxy(2014鞍山赛区现场赛D题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5073 解题报告:在一条直线上有n颗星星,一开始这n颗星星绕着重心转,现在我们可以把其中的任意k颗星星移 ...

  8. HDU 5071 Chat(2014鞍山赛区现场赛B题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 解题报告:一个管理聊天窗口的程序,一共有八种操作,然后要注意的就是Top操作只是把编号为u的窗口 ...

  9. hdu 5542 The Battle of Chibi(2015CCPC - C题)

    题目链接:hdu 5542 首届CCPC的C题,比赛时一起搞了好久,最后是队友A出的,当时有试过用树状数组来优化 dp,然后今天下午也用树状数组搞了一下午,结果还是踩了和当时一样的坑:我总是把用来记录 ...

随机推荐

  1. mac安装webpack失败

    最近开始接触构建工具webpack,公司电脑是 windows,而我自己的呢是mac.本来以为在自己电脑安装很简单,但是出了点问题,所以写出来分享下. 这里用npm的方式安装,首先你要安装node.j ...

  2. Python2 和Python3 的区别

    print Python 2中的print语句被Python 3中的print()函数取代,这意味着在Python 3中必须用括号将需要输出的对象括起来. 在Python 2中使用额外的括号也是可以的 ...

  3. SD Card Formatter for Mac Download

    https://www.sdcard.org/downloads/formatter_4/eula_mac/ SDFormatter Mac版是一款Mac OS平台上的sd卡修复工具,SDFormat ...

  4. WINDOWS-基础:SafeArray的使用方法

    1 SafeArray的作用 使用SafeArray SafeArray是VB中的数组存储方式.通过SafeArray,可以在VC++和VB间相互调用. SafeArray也是Automation中的 ...

  5. js完成打印功能

    最近在做项目要求实现打印功能,我采用js方式来实现 window.print();会弹出打印对话框,打印的是window.docunemt.body.innerHTML中的内容,可以局部打印,也可以全 ...

  6. Bootstrap 页面标题(Page Header)

    Bootstrap页面标题(PageHeader)是个不错功能,它会网页的标题的四周添加适当的间距,当一个网页中有多个标题并且每个标题之间需要添加一定适当的间距,使用页面标题是非常有用的.如果需要使用 ...

  7. shell脚本,awk利用NF来计算文本显示的行数。

    解释: 1.awk 'NF{a++;print a,$0;next}1' file4 首先判断NF是否存在值,第一行第二行第三行第四行都存在,进行执行后面的输出,输出后碰到next后,就结束了后面的操 ...

  8. java String中的replace(oldChar,newChar) replace(CharSequence target,CharSequence replacement) replaceAll replaceFirst 面试题:输入英文语句,单词首字符大写后输出 char String int 相互转换

    package com.swift; import java.util.Scanner; public class FirstChat_ToCaps_Test { public static void ...

  9. 【转】LDA-linear discriminant analysis

    分类问题也可以用降维来理解,比如一个D维的数据点x,我们可以采用下面的映射进行线性的降维, y=θTx 在计算出y后,就可以选择一个阈值h,来进行分类.正如我们在前面的PCA模型中看到的,降维会有信息 ...

  10. Eclipse使用Mybatis-Generator插件

    Mybatis-Generator插件极大地方便了我们的开发效率,不用每张表每个字段人工去敲,所以本文介绍使用Mybatis-Generator自动生成Dao.Model.Mapping相关文件 版权 ...