POJ 2141 Message Decowding(map)

Message Decowding

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 11735   Accepted: 6536

Description

The cows are thrilled because they‘ve just learned about encrypting messages. They think they will be able to use secret messages to plot meetings with cows on other farms.

Cows are not known for their intelligence. Their encryption method is nothing like DES or BlowFish or any of those really good secret coding methods. No, they are using a simple substitution cipher.

The cows have a decryption key and a secret message. Help them decode it. The key looks like this:

        yrwhsoujgcxqbativndfezmlpk

Which means that an ‘a‘ in the secret message really means ‘y‘; a ‘b‘ in the secret message really means ‘r‘; a ‘c‘ decrypts to ‘w‘; and so on. Blanks are not encrypted; they are simply kept in place.

Input text is in upper or lower case, both decrypt using the same decryption key, keeping the appropriate case, of course.

Input

* Line 1: 26 lower case characters representing the decryption key

* Line 2: As many as 80 characters that are the message to be decoded

Output

* Line 1: A single line that is the decoded message. It should have the same length as the second line of input.

Sample Input

eydbkmiqugjxlvtzpnwohracsf
Kifq oua zarxa suar bti yaagrj fa xtfgrj

Sample Output

Jump the fence when you seeing me coming
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<map>
using namespace std;
int main()
{
    map <char,char> record;
    map<char, char >::iterator  it;
    char str1[26],str2[101];
    int i;
    for(i=0;i<26;i++)
    {
        cin>>str1[i];
        record[i+'a']=str1[i];
    }
    getchar();
    gets(str2);
    int len;
    len=strlen(str2);

    for(i=0;i<len;i++)
    {
        if(str2[i]==' ')
        {
            cout<<" ";
            continue;
        }
        else if(str2[i]>='A'&&str2[i]<='Z')
        {
            it=record.find(str2[i]+32);
            cout<<char(it->second-32);
        }
        else
        {
            it=record.find(str2[i]);
            cout<<it->second;
        }
    }
	cout<<endl;
    return 0;
}

POJ 2141 Message Decowding(map)

时间: 2024-10-15 23:59:53

POJ 2141 Message Decowding(map)的相关文章

POJ 2141 Message Decowding(简单题)

[题意简述]:这个题目描述非常简单,不再赘述. [分析]:直接把那个输入的字符,当做是key值数组的下标即可. //164K 16Ms #include<iostream> using namespace std; char Key[27]; char decoded [81]; int main() { gets(Key); gets(decoded); for(int i = 0;i<strlen(decoded);i++) { if(decoded[i]>='A'&&

OpenJudge / Poj 2141 Message Decowding

1.链接地址: http://poj.org/problem?id=2141 http://bailian.openjudge.cn/practice/2141/ 2.题目: Message Decowding Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11784   Accepted: 6562 Description The cows are thrilled because they've just learn

POJ 2503 单词映射(map)

Sample Input dog ogdaycat atcaypig igpayfroot ootfrayloops oopslay atcayittenkayoopslaySample Output catehloops 大致题意:输入一个字典,字典格式为“英语à外语”的一一映射关系然后输入若干个外语单词,输出他们的 英语翻译单词,如果字典中不存在这个单词,则输出“eh” 输入时顺便用STL的map标记外语是否出现过,然后再用map建立“外语à英语”的映射,那么输出时先查找“出现”的标记,若有

poj 3440 Coin Toss(概率)

http://poj.org/problem?id=3440 大致题意:给出一个n*m的格子,每个格子的边长为t,随意抛一枚硬币并保证硬币的圆心在格子里或格子边上,硬币的直径为c,求硬币覆盖格子的个数的概率. 思路:高中的概率题,ms是几何概型.根据分别覆盖1,2,3,4个格子时圆心可分部的面积比上总面积就是答案. #include <stdio.h> #include <iostream> #include <algorithm> #include <set&g

POJ题目Java代码(一)

POJ 1001 Exponentiation import java.math.BigDecimal; import java.util.Scanner; public class Poj1001 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ BigDecimal bigDecimal = new BigDecimal(sc.next())

poj 4044 Score Sequence(暴力)

http://poj.org/problem?id=4044 大致题意:给出两个班级的成绩,先按降序排序,并且没有成绩相同的.然后求连续的最长公共子序列.输出时,先输出最长公共子序列,然后按个位数字递增的顺序输出,若各位数字一样就按成绩递增. 人数小于30,注意去重,直接暴力即可. #include <stdio.h> #include <iostream> #include <map> #include <stack> #include <vecto

【POJ 3071】 Football(DP)

[POJ 3071] Football(DP) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4350   Accepted: 2222 Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In each round of the tournament, all tea

【POJ 3034】 Whac-a-Mole(DP)

[POJ 3034] Whac-a-Mole(DP) Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3621   Accepted: 1070 Description While visiting a traveling fun fair you suddenly have an urge to break the high score in the Whac-a-Mole game. The goal of the W

POJ 2299 逆序对(归并排序)

终于解决了一个忧伤好久的问题,严重拖了项目进度,深感惭愧!一直被一系列的问题所困扰,然后又只能自己一个人摸索,也是一段辛酸忧伤史,现在小结一下上个月在做二维码的过程中所碰到的问题以及解决办法,现在庆幸终于解决好了,终于能将这个功能告一段落,一下小结也是分享一下Unity的某些"坑",让同行少走弯路,起码在二维码这方面应该会有所启迪,欣慰的是接下来几天终于可以做自己应该做的事情了! 效果图: 先小结一下碰到的问题: 1.Unity工程屏幕方向与Android工程屏幕方向要一致的问题 本来