ACM--字母增加--HDOJ 1328--IBM Minus One--字符串

HDOJ题目地址:传送门

IBM Minus One

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 5597    Accepted Submission(s): 2855

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

题意:就是模拟,字母变成自己后面的字母

#include<stdio.h>
#include<string.h>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,len,index=1;
    string s;
    cin>>n;
    getchar();
    while(n--){
        getline(cin,s);
        len=s.size();
        printf("String #%d\n",index++);
        for(int i=0;i<len;i++){
            if(s[i]=='Z'){
                printf("A");
            }else{
                printf("%c",((s[i]-'0'+1)+'0'));
            }

        }
            printf("\n\n");

    }
}
时间: 2024-08-26 05:28:16

ACM--字母增加--HDOJ 1328--IBM Minus One--字符串的相关文章

HDU 1328 IBM Minus One (水)

IBM Minus One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4036    Accepted Submission(s): 2104 Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clark

(HDUStep 1.2.7)IBM Minus One(字符串运算)

题目: IBM Minus One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3943 Accepted Submission(s): 1519   Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clark

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 tw

IBM Minus One(water)

IBM Minus One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4475    Accepted Submission(s): 2349 Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke

hdoj 2072 单词数 【字符串处理】

题目大意: 输入一组字符串,只由小写字母和空格组成,让你统计不同单词的个数,注意是不同的个数 . 特殊数据 1,直接输入一个换行,应该输出0 2,连续输出多个空格 在加上一个换行 应该输出0 3,输入 "ni shi wo wo de de de de hao     hao "应该输出5 6, 输入" 空格空格ni空格空格shi     " 应该输出2 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2072 #in

魔咒词典------HDOJ杭电1880(字符串的处理,很简单)

Problem Description 哈利波特在魔法学校的必修课之一就是学习魔咒.据说魔法世界有100000种不同的魔咒,哈利很难全部记住,但是为了对抗强敌,他必须在危急时刻能够调用任何一个需要的魔咒,所以他需要你的帮助. 给你一部魔咒词典.当哈利听到一个魔咒时,你的程序必须告诉他那个魔咒的功能:当哈利需要某个功能但不知道该用什么魔咒时,你的程序要替他找到相应的魔咒.如果他要的魔咒不在词典中,就输出"what?" Input 首先列出词典中不超过100000条不同的魔咒词条,每条格式

Map集合应用 取出一个字符串中字母出现的次数。如:字符串:&quot;abcdekka27qoq&quot;&#160;,输出格式为:a(2)b(1)k(2)...

package com.swift; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Test3_String_char { public static void main(String[] args) { /* * 第4题: 取出一个字符串中字母出现的次数.如:字符串:

IBM Minus One

描述 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,

HDOJ/HDU 1062 Text Reverse(字符串翻转~)

Problem Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the inpu