zoukankan      html  css  js  c++  java
  • UVALive 5880 Vigenère Cipher Encryption (模拟)

    Stack Machine Executor

    题目链接:

    http://acm.hust.edu.cn/vjudge/problem/26628

    Description

    http://7xjob4.com1.z0.glb.clouddn.com/18113a5cf78f108997460e36f7079fc6

    Input

    The input contains several instances. Each instance consists of two lines, the first line is the encryption key and the second line is the plaintext. Both key and plaintext consist of uppercase letters of the English alphabet {A, B, C, . . . , Z}. The length of the key will be between 1 and 1000, the length of the plaintext between 1 and 100 000, inclusive. Input is terminated by a line containing one zero.

    Output

    For each input instance, output the ciphertext — the encrypted version of the message.

    Sample Input

    ICPC THISISSECRETMESSAGE ACM CENTRALEUROPEPROGRAMMINGCONTEST LONGKEY CERC 0

    Sample Output

    CKYVRVIHLUUWVHIVJJU DHAUUNMHHSRCFSEPJEBPZJQTDRAUHFU OTFJ

    Source

    2016-HUST-线下组队赛-1
    ##题意: 用密钥来加密字符串.
    ##题解: 题目真是长,然而是签到题... 要练习一下快速读题了...不要看到长题面不敢读.. 直接模拟即可.
    ##代码: ``` cpp #include #include #include #include #include #include #include #include #include #include #include #define LL long long #define eps 1e-8 #define maxn 101000 #define mod 100000007 #define inf 0x3f3f3f3f #define mid(a,b) ((a+b)>>1) #define IN freopen("in.txt","r",stdin); using namespace std;

    char str[maxn];
    char key[maxn];

    int main(int argc, char const *argv[])
    {
    //IN;

    while(gets(key) && key[0] != '0')
    {
        gets(str);
    
        int klen = strlen(key);
        int len = strlen(str);
    
        for(int i=0,j=0; i<len; i++,j++) {
            if(j == klen) j = 0;
            str[i] = (str[i] + key[j] - 'A' + 1 - 'A') % 26 + 'A';
        }
    
        puts(str);
    }
    
    return 0;
    

    }

  • 相关阅读:
    del命令
    echo命令
    什么是批处理
    ubuntu禁止ping操作(禁用ICMP协议访问)
    树莓派:raspberry pi 3b
    小tips合集
    吐个槽:bose的售后真心差劲!愧对这个顶级音响产品!
    WinSetupFromUSB
    win7 64位下vs不能以管理员身份运行的问题解决
    vs2010中如何设置Visual Assist方便地使用现成的代码编辑器风格
  • 原文地址:https://www.cnblogs.com/Sunshine-tcf/p/5791209.html
Copyright © 2011-2022 走看看