洛谷 P1914 小书童——凯撒密码 C/C++ 字符串

不需要开数组 边读边处理
//P1914 小书童——凯撒密码
#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cctype>
#define inf 0x3f3f3f3f
#define eps 1e-6
using namespace std;
#define clr(x) memset(x,0,sizeof((x)))
const int maxn = 5e4+1;//2e6+1
#define MAX(a,b,c) ((a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c)))
#define _max(a,b) ((a) > (b) ? (a) : (b))
#define _min(a,b) ((a) < (b) ? (a) : (b))
#define _for(a,b,c) for(int a = b;a<c;a++)
int readchar() {
    
    
	int ch;
	for(;;) {
    
    
		ch = getchar();
		if(ch!='\n'&&ch!='\r')return ch;
	}
}
int main() {
    
    
#ifdef LOCAL 
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
#endif
	int n,c,x;
	cin>>n;
	while((c = readchar())!=EOF) {
    
    
		x = (c-'a'+n)%26;
		printf("%c",'a'+x);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Jason__Jie/article/details/112438078