码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces - 102222C - Caesar Cipher

时间:2019-06-17 00:30:30      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:putc   uri   ||   shift   test   include   getc   左右   for   

https://codeforc.es/gym/102222/my
好像在哪里见过这个东西?字符的左右移还是小心,注意在mod26范围内。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

inline int read() {
    int x=0;
    int f=0;
    char c;
    do {
        c=getchar();
        if(c=='-')
            f=1;
    } while(c<'0'||c>'9');
    do {
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    } while(c>='0'&&c<='9');
    return f?-x:x;
}

inline void _write(int x) {
    if(x>9)
        _write(x/10);
    putchar(x%10+'0');
}

inline void write(int x) {
    if(x<0) {
        putchar('-');
        x=-x;
    }
    _write(x);
    putchar('\n');
}

void TestCase(int ti);

int main() {
#ifdef Yinku
    freopen("Yinku.in","r",stdin);
    //freopen("Yinku.out","w",stdout);
#endif // Yinku
    int T=read();
    for(int ti=1;ti<=T;ti++)
        TestCase(ti);
}

/*---  ---*/

char p[60],c[60],p2[60],c2[60];
char t[256];

void TestCase(int ti) {
    int n=read(),m=read();
    scanf("%s%s%s",p,c,c2);
    int rightshift=c[0]-p[0];
    if(rightshift<0)
        rightshift+=26;
    for(int i=0;i<m;i++){
        p2[i]=c2[i]-rightshift;
        if(p2[i]<'A')
            p2[i]+=26;
    }
    p2[m]='\0';
    printf("Case #%d: ",ti);
    puts(p2);
}

Codeforces - 102222C - Caesar Cipher

标签:putc   uri   ||   shift   test   include   getc   左右   for   

原文地址:https://www.cnblogs.com/Yinku/p/11037534.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!