IBM Minus One


Time Limit:
2 Seconds      Memory Limit:
65536 KB


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


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
char dic[]={' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
void _solve(string s)
{
for(int i=0;i<s.length();i++)
{
if(s[i]=='Z') cout<<'A';
else {
int j=0;
while(dic[j]!=s[i]) j++;
cout<<dic[j+1];
}
}
}
int main()
{
int n;
string str;
cin>>n;
for(int v=1;v<=n;v++)
{
cin>>str;
cout<<"String #"<<v<<endl;
_solve(str);
cout<<endl<<endl;
}
return 0;
}

非打表的编码处理方式:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
void _solve(string s)
{
for(int i=0;i<s.length();i++)
{
if(s[i]=='Z') cout<<'A';
else cout<<char(s[i]+1);
}
}
int main()
{
int n;
string str;
cin>>n;
for(int v=1;v<=n;v++)
{
cin>>str;
cout<<"String #"<<v<<endl;
_solve(str);
cout<<endl<<endl;
}
return 0;
}

IBM Minus One 简单字符处理的更多相关文章

  1. Linux 简单字符设备驱动程序 (自顶向下)

    第零章:扯扯淡 特此总结一下写的一个简单字符设备驱动程序的过程,我要强调一下“自顶向下”这个介绍方法,因为我觉得这样更容易让没有接触过设备驱动程序的童鞋更容易理解,“自顶向下”最初从<计算机网络 ...

  2. IBM Minus One(water)

    IBM Minus One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. HDU 1328 IBM Minus One

    IBM Minus One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. IBM Minus One

    IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  5. 【Linux-驱动】简单字符设备驱动结构和初始化

    (1)在编写简单字符设备驱动的时候,首先要申请一个设备结构struct cdev: struct cdev { struct kobject kobj; struct module *owner; / ...

  6. 【转】linux设备驱动程序之简单字符设备驱动

    原文网址:http://www.cnblogs.com/geneil/archive/2011/12/03/2272869.html 一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用 ...

  7. 简单字符串匹配 Brute

    /* 很简单 模式匹配的Brute-Force算法 Brute-Force算法实现模式匹配的思想是:从主串s=”s0s1…sn-1”的第一个字符开始和模式串t=”t0t1…tn-1”的第一个字符比较, ...

  8. arm-linux字符设备驱动开发之---简单字符设备驱动

    一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用驱动程序: 1.字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据,读取数据需要按照先后数据.字符设备是面 ...

  9. ZOJ 1240 IBM Minus One

    /* You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the s ...

随机推荐

  1. 操作系统:ucore的部分Bug&挑战练习

    ucore是清华大学提供的一个学习操作系统的平台.ucore有完整的mooc视频与说明文档. https://objectkuan.gitbooks.io/ucore-docs/content/# 本 ...

  2. NET Core度身定制的AOP框架

    NET Core度身定制的AOP框架 多年从事框架设计开发使我有了一种强迫症,那就是见不得一个应用里频繁地出现重复的代码.之前经常Review别人的代码,一看到这样的程序,我就会想如何将这些重复的代码 ...

  3. 201521123107 《Java程序设计》第11周学习总结

    第11周作业-多线程 1.本周学习总结 2.书面作业 本次PTA作业题集多线程 1.互斥访问与同步访问 完成题集4-4(互斥访问)与4-5(同步访问) 1.1 除了使用synchronized修饰方法 ...

  4. 201521123036 《Java程序设计》第4周学习总结

    本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 继承:extends子类将获得父类的属性与方法,并具有自身特有的属性与方法 抽取共同特征(行为与属 ...

  5. Java课程设计—学生成绩管理系统(201521123005 杨雪莹)

    一.团队课程设计博客链接 学生成绩管理系统 二.个人负责模块或任务说明 学生成绩录入 显示所有学生信息 显示各科平均成绩 显示学生成绩(按降序排序) 三.自己的代码提交记录截图 四.自己负责模块或任务 ...

  6. 域名解析>>"记录类型" 说明

    (1)A (Address) 记录是用来指定主机名(或域名)对应的IP地址记录. 说明:用户可以将该域名下的网站服务器指向到自己的web server上.同时也可以设置自己域名的二级域名. (2)MX ...

  7. Mybatis第九篇【基于Maven在Idea下Mybatis逆向工程】

    前言 在Intellij idea下,没有学习Maven的情况下使用Mybatis的逆向工程好像有点复杂,资料太少了-找到的资料好像也行不通- 于是学完Maven之后,我就再来更新Idea下使用Myb ...

  8. Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual tha

    使用了数据库的关键字index,如果有类似的错误,看看自己有没有使用关键字!

  9. Hibernate由model类自动同步数据库表结构

    在开发中遇到了个问题,每次测试数据库增加表结构的时候,本地pull下最新代码导致启动报错,上网搜了快速解决办法---->hibernate 配置属性中,hibernate.hbm2ddl.aut ...

  10. 实验:体会Oracle权限/角色赋予的差异

    环境:Oracle 11.2.0.4 目的:验证业务用户的权限/角色赋予的差异 现在创建两个用户jingyu2和jingyu3: SYS@jyzhao1> create user jingyu2 ...