IBM Minus One 简单字符处理
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 简单字符处理的更多相关文章
- Linux 简单字符设备驱动程序 (自顶向下)
第零章:扯扯淡 特此总结一下写的一个简单字符设备驱动程序的过程,我要强调一下“自顶向下”这个介绍方法,因为我觉得这样更容易让没有接触过设备驱动程序的童鞋更容易理解,“自顶向下”最初从<计算机网络 ...
- IBM Minus One(water)
IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- HDU 1328 IBM Minus One
IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- IBM Minus One
IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- 【Linux-驱动】简单字符设备驱动结构和初始化
(1)在编写简单字符设备驱动的时候,首先要申请一个设备结构struct cdev: struct cdev { struct kobject kobj; struct module *owner; / ...
- 【转】linux设备驱动程序之简单字符设备驱动
原文网址:http://www.cnblogs.com/geneil/archive/2011/12/03/2272869.html 一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用 ...
- 简单字符串匹配 Brute
/* 很简单 模式匹配的Brute-Force算法 Brute-Force算法实现模式匹配的思想是:从主串s=”s0s1…sn-1”的第一个字符开始和模式串t=”t0t1…tn-1”的第一个字符比较, ...
- arm-linux字符设备驱动开发之---简单字符设备驱动
一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用驱动程序: 1.字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据,读取数据需要按照先后数据.字符设备是面 ...
- 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 ...
随机推荐
- 操作系统-实验一、DOS使用命令实验
实验一.DOS使用命令实验 一.实验目的 DOS是市场上早期获得巨大成功的桌面操作系统,现在很多同学都不太熟悉.本实验的目的就是让同学们读者从操作系统理论的观点来重新认识它们,了解和掌握DO ...
- NHibernate教程(18)--对象状态
本节内容 引入 对象状态 对象状态转换 结语 引入 在程序运行过程中使用对象的方式对数据库进行操作,这必然会产生一系列的持久化类的实例对象.这些对象可能是刚刚创建并准备存储的,也可能是从数据库中查询的 ...
- MPLS VPN随堂笔记1
MPLS VPN 基础 1.MPLS vpn架构的特点 1.1.允许不同CE传递相同私网路由 1.2.SP内部(所有P路由器)不需要学习CE路由 1.3.无安全保障但有带宽保障(跟SP租用服务) 2. ...
- spring的配置文件和加载
①:创建applicationContext.xml配置文件放在src下 //applicationContext.xml代码 <?xml version="1.0" enc ...
- Swing-setOpaque()用法-入门
先看API: public void setOpaque(boolean isOpaque) 如果为 true,则该组件绘制其边界内的所有像素.否则该组件可能不绘制部分或所有像素,从而允许其底层像素透 ...
- 201521123066 《Java程序设计》 第六周学习总结
1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图,对面向对象思想进行一个总结. 1.clone方法 1.1 Object对象中的clone ...
- 201521123074 《Java程序设计》第2周学习总结
1.本周学习总结 学习了string类的一些用法,Java编写大致与c相同,但是要注意Java是面向对象的语言.例如两个字符串"=="比较,Java与c可能会有不同结果. 学习了i ...
- Python IDLE快捷键一览
编辑状态时:Ctrl + [ .Ctrl + ] 缩进代码Alt+3 Alt+4 注释.取消注释代码行Alt+5 Alt+6 切换缩进方式 空格<=>TabAlt+/ 单词完成,只要文中出 ...
- JAVA课设 学生基本信息管理 团队博客
1.成员 邹其元 网络1512 201521123060 杨钧宇 网络1512 201521123062 2.项目Git地址 团队项目码云地址 //添加截图 3. 项目git提交记录截图(要体现出每个 ...
- HTTP第一篇
为什么要学HTTP? 我们绝大多数的Web应用都是基于HTTP来进行开发的.我们对Web的操作都是通过HTTP协议来进行传输数据的. HTTP的诞生主要是为了能够让文档之间相互关联,形成超文本可以互相 ...