zoukankan      html  css  js  c++  java
  • B?Cryptoquote

    B ? Cryptoquote

    时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte
    总提交 : 42            测试通过 : 22 

    题目描述

    cryptoquote is a simple encoded message where one letter is simply replaced by anotherthroughout the message. For example:

    Encoded: HPC PJVYMIY

    Decoded: ACM CONTEST

    In the example above, H=AP=CC=MJ=OV=NY=TM=E and I=S. For this problem, you willdecode messages.



    输入

    The first line of input contains a single integer N, (1 £ £ 1000) which is the number of data sets thatfollow. Each data set consists of two lines of input. The first line is the encoded message. Thesecond line is a 26 character string of upper case letters giving the character mapping for each letterof the alphabet: the first character gives the mapping for A, the second for and so on. Only uppercase letters will be used. Spaces may appear in the encoded message, and should be preserved inthe output string.

    输出

    For each data set, you should generate one line of output with the following values: The data setnumber as a decimal integer (start counting at one), a space and the decoded message.

    样例输入

    2
    HPC PJVYMIY
    BLMRGJIASOPZEFDCKWYHUNXQTV
    FDY GAI BG UKMY
    KIMHOTSQYRLCUZPAGWJNBVDXEF

    样例输出

    1 ACM CONTEST
    2 THE SKY IS BLUE

    #include<iostream>
    #include<string.h>
    #include<string>
    #include<stdlib.h>
    #include<stdio.h>
    using namespace std;
    int T;
    const int N=100;
    int main(){
        scanf("%d",&T);
        int pp=T;
        while(T--){
            getchar();
            char s[N],a[27];;
            gets(s);
            for(int i=1;i<27;i++){
                cin>>a[i];
            }
            cout<<pp-T<<" ";
            for(int i=0;i<strlen(s);i++){
                if(s[i]=='A'){
                    cout<<a[1];
                }
                else if(s[i]=='B'){
                    cout<<a[2];
                }
                else if(s[i]=='C'){
                    cout<<a[3];
                }
                else if(s[i]=='D'){
                    cout<<a[4];
                }
                else if(s[i]=='E'){
                    cout<<a[5];
                }
                else if(s[i]=='F'){
                    cout<<a[6];
                }
                else if(s[i]=='G'){
                    cout<<a[7];
                }
                else if(s[i]=='H'){
                    cout<<a[8];
                }
                else if(s[i]=='I'){
                    cout<<a[9];
                }
                else if(s[i]=='J'){
                    cout<<a[10];
                }
                else if(s[i]=='K'){
                    cout<<a[11];
                }
                else if(s[i]=='L'){
                    cout<<a[12];
                }
                else if(s[i]=='M'){
                    cout<<a[13];
                }
                else if(s[i]=='N'){
                    cout<<a[14];
                }
                else if(s[i]=='O'){
                    cout<<a[15];
                }
                else if(s[i]=='P'){
                    cout<<a[16];
                }
                else if(s[i]=='Q'){
                    cout<<a[17];
                }
                else if(s[i]=='R'){
                    cout<<a[18];
                }
                else if(s[i]=='S'){
                    cout<<a[19];
                }
                else if(s[i]=='T'){
                    cout<<a[20];
                }
                else if(s[i]=='U'){
                    cout<<a[21];
                }
                else if(s[i]=='V'){
                    cout<<a[22];
                }
                else if(s[i]=='W'){
                    cout<<a[23];
                }
                else if(s[i]=='X'){
                    cout<<a[24];
                }
                else if(s[i]=='Y'){
                    cout<<a[25];
                }
                else if(s[i]=='Z'){
                    cout<<a[26];
                }
                else if(s[i]==' '){
                    cout<<' ';
                }
            }
            cout<<endl;
        }
    }


    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    已知sim3相似变换矩阵,如何求解出R, s, t ,从sim3相似变换矩阵中恢复和获得尺度、旋转、平移
    dynamic_cast用法总结
    为什么不建议用 equals 判断对象相等?
    玩转 Java 动态编译,秀了秀了~!
    如何不改表结构动态扩展字段?
    Java 中 long 是不是原子操作?
    7 个超实用的 MySQL 语句写法,让同事们眼前一亮!
    Spring Boot 集成 Flyway,数据库也能做版本控制,太牛逼了!
    Dubbo 的设计思想,真优秀!
    一个高性能、小而美的序列化工具!
  • 原文地址:https://www.cnblogs.com/Tobyuyu/p/4965705.html
Copyright © 2011-2022 走看看