计蒜客之模拟篇

版权声明:欢迎指出文章不足之处~~~ https://blog.csdn.net/zhui_xiuge/article/details/81097494
  1. Caesar Cipher
#include <stdio.h>
#define LEN 55

int t, n, m;
char plaintext[2][LEN], ciphertext[2][LEN];
int h[2][26];

int main() {
    scanf("%d", &t);
    for (int i = 1; i <= t; i++) {
        scanf("%d%d", &n, &m);
        scanf("%s%s%s", plaintext[0], ciphertext[0], ciphertext[1]);
        int shift = plaintext[0][0] - ciphertext[0][0]; //或者相反
        for (int i = 0; i < m; i++) plaintext[1][i] = (ciphertext[1][i] - 'A' + shift + 26) % 26 + 'A';
        plaintext[1][m] = '\0'; //多组cases
        printf("Case #%d: %s\n", i, plaintext[1]);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/zhui_xiuge/article/details/81097494