Moota @ 2020-09-11 20:04:11
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
int n;
cin >> n;
string str;
cin >> str;
int size = str.size();
for (int i = 0; i < size; i++) {
// char j = str[i];
//j += n;
//str[i]='a' +(j-'a')%26;
str[i] = 'a' + (str[i] + n - 'a') % 26;
}
cout << str;
return 0;
}
by Moota @ 2020-09-11 20:08:41
诡异
by gxy001 @ 2020-09-11 20:14:02
@Moota char(-128~127)(j-'a')
显然爆了,str[i] + n - 'a'
,n
是int,所以转化为int计算,不爆
by Moota @ 2020-09-11 20:19:21
@gxy001谢谢大佬