HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description
You may have heard of the book ‘2001 - A Space Odyssey’ by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In it a spaceship is sent from Earth to Saturn. The crew is put into stasis for the long flight, only two men are awake, and the ship is controlled by the intelligent computer HAL. But during the flight HAL is acting more and more strangely, and even starts to kill the crew on board. We don’t tell you how the story ends, in case you want to read the book for yourself :-)
After the movie was released and became very popular, there was some discussion as to what the name ‘HAL’ actually meant. Some thought that it might be an abbreviation for ‘Heuristic ALgorithm’. But the most popular explanation is the following: if you replace every letter in the word HAL by its successor in the alphabet, you get … IBM.
Perhaps there are even more acronyms related in this strange way! You are to write a program that may help to find this out.
Input
The input starts with the integer n on a line by itself - this is the number of strings to follow. The following n lines each contain one string of at most 50 upper-case letters.
Output
For each string in the input, first output the number of the string, as shown in the sample output. The print the string start is derived from the input string by replacing every time by the following letter in the alphabet, and replacing ‘Z’ by ‘A’.
Print a blank line after each test case.
Sample Input
2
HAL
SWERC
Sample Output
String #1
IBM
String #2
TXFSD
题意就是:输入一个大写的字符串,输出每一个大写字母后的一个大写字母。
如果遇到Z就输出A。
注意每一个测试后都有一个空行。
水题一个!
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t =sc.nextInt();
int ti=0;
while(t-->0){
String str = sc.next();
System.out.println("String #"+(++ti));
for(int i=0;i<str.length();i++){
if(str.charAt(i)=='Z'){
System.out.print("A");
}else{
System.out.print((char)(str.charAt(i)+1));
}
}
System.out.println();
System.out.println();
}
}
}
HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)的更多相关文章
- HDOJ(HDU) 2090 算菜价(简单水题、)
Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...
- HDOJ(HDU) 1555 How many days?(水题)
Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...
- HDU 1328 IBM Minus One
IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDOJ/HDU 2537 8球胜负(水题.简单的判断)
Problem Description 8球是一种台球竞赛的规则.台面上有7个红球.7个黄球以及一个黑球,当然还有一个白球.对于本题,我们使用如下的简化规则:红.黄两名选手轮流用白球击打各自颜色的球, ...
- HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,J ...
- HDOJ/HDU 2561 第二小整数(水题~排序~)
Problem Description 求n个整数中倒数第二小的数. 每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1. Input 输入包含多组测试数据. 输入的第 ...
- HDOJ(HDU) 1562 Guess the number(水题,枚举就行)
Problem Description Happy new year to everybody! Now, I want you to guess a minimum number x betwwn ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
- HDU 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
随机推荐
- 2016.08.06计算几何总结测试day1
T1 bzoj1132[POI2008]TRO 还是太弱了....测试时看到这题直接懵逼,极角排序什么的根本想不起来,只会n^3暴力怎么破......不过竟然有84.....QAQ 正解是n^2log ...
- JS当前日期相加相减
function DateAddORSub(interval,type,number) { /* * 功能:实现Script的Date加减功能. * 参数:interval,字符串表达式,表示要添加的 ...
- centos 软件安装 删除
centos的软件安装大致可以分为两种类型: [centos]rpm文件安装,使用rpm指令 类似[ubuntu]deb文件安装,使用dpkg指令 [centos]yum安装 类似[ubuntu ...
- 『奇葩问题集锦』Ruby 切换淘宝源报错WARNING: Error fetching data: SSL_connect returned=1 errno=0 state=SSLv3 read s erver certificate B: certificate verify failed
===>首先需要使用https<===https://ruby.taobao.org/ 第一步 下载http://pan.baidu.com/s/1kU0rxtH 复制到ruby安装的根目 ...
- 简易的RestClient代码
package tests; import java.io.*; import org.apache.http.HttpEntity; import org.apache.http.HttpRespo ...
- Eyeshot Ultimate 学习笔记(2)
导入模型 一般情况下,我们自己搭建模型的功力还不够,大多都是在3Dmax中做好模型,导出成模型文件,然后再导入Eyeshot视图中.导入的代码包括: OpenFileDialog openFileDi ...
- yum使用详细
1.使用YUM查找软件包 命令:yum search~ 2.列出所有可安装的软件包 命令:yum list 3.列出所有可更新的软件包 命令:yum list updates 4.列出所有已安装的软件 ...
- python 输出小数控制
一.要求较小的精度 将精度高的浮点数转换成精度低的浮点数. 1.round()内置方法round()不是简单的四舍五入的处理方式. >>> round(2.5) 2 >> ...
- 向OC类中添加默认的协议实现(ProtocolKit)
以forkingdog的PorotocolKit举例 举例 ProtocolKit Protocol extension for Objective-C Usage Your protocol: @p ...
- CSS3 calc() 会计算的属性
calc是英文单词calculate(计算)的缩写,是css3的一个新增的功能,你可以使用calc()给元素的border.margin.pading.font-size和width等属性设置动态值. ...