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. distinct和group by 去掉重复数据分析

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp40 用distinct关键字只能过滤查询字段中所有记录相同的(记录集相同) ...

  2. hdu 3062 2-Sat入门

    开始学习2-Sat,前面看了对称性解决2-sat的ppt,很有帮助. 题意:n对夫妻,夫妻需要出席一人,给出不相容的关系,求每对是否能完成出席方案. 思路:通过关系建图,Tarjan缩点,然后进行判断 ...

  3. JavaScript学习日志(一):变量,作用域和内存问题

    一,变量分为两种类型:基本类型值和引用类型值,基本类型包括:Undefined, String, Boolean, Null, Number,我们无法给基本类型值添加属性: 二,复制变量值的时候,如果 ...

  4. OSI与TCP/IP网络模型分层

      学习linux的人,都会接触到一些网络方面的知识.作为一个linux方面的萌新,今天,小编就接触了OSI模型和TCP/IP协议栈,那么什么是OSI模型呢?     OSI模型,开放式系统互联通信参 ...

  5. nhibernate教程(4)--条件查询(Criteria Query)

    NHibernate之旅(4):探索查询之条件查询(Criteria Query) 2008-10-16 18:20 by 李永京, 44341 阅读, 43 评论, 收藏,  编辑 本节内容 NHi ...

  6. JavaScript封装一个MyAlert弹出框

    平时我们想要显示一些提示信息时会用到alert方法,alert是全局的一个方法,会短暂的中断程序,我们主要用来显示提示客户信息.但是这个方法有一定的局限性,而且本身样式也不够美观.于是我封装了一个实用 ...

  7. Linux运维:安装CentOS7.2-图解

    矮哥linux运维群: 93324526 笔者QQ:578843228 此篇博文针对最小化安装,和只有图解.有不懂地方,欢迎加群询问.

  8. JQuery实用技巧--学会你也是大神(1)——插件的制作技巧

      前  言 JRedu 学习之前,首先我们需要知道什么是JQuery? JQuery是一个优秀的javascript框架. JQuery是继Prototype之后又一个优秀的Javascript框架 ...

  9. css3 如何实现圆边框的渐变

    使用 css 实现下面效果: 把效果分解. 代码一: <style> .helper1 { height: 40px; padding: 15px; background: -webkit ...

  10. 【Alpha】阶段 第七次 Scrum Meeting

    每日任务 1.本次会议为第一次 Meeting会议: 2.本次会议在下午14:45,课间休息时间在禹州楼召开,召开本次会议为10分钟,根据大家的讨论分析得出的总结,讨论下接下来版本的改进计划: 一.今 ...