houfuhao @ 2019-06-15 19:43:58
using namespace std; int main() { int n; char c; string s; scanf_s("%d", &n); getchar(); while(1) { scanf_s("%c", &c); if (c == '\n') break; if ((int)c + n > 122) c = (char)((int)c - 26 + n); else c = (char)((int)c + n); s.push_back(c); } cout << s ; return 0; }
by yyk504 @ 2019-06-15 20:00:51
希望更丰富的展现?使用Markdown
by 已注销ZdCpmQy3 @ 2019-06-15 20:11:40
来,我帮你整理下:
include <iostream>
include <string>
using namespace std;
int main() {
int n;
char c;
string s;
scanf_s("%d", &n);
getchar();
while(1) {
scanf_s("%c", &c);
if (c == '\n') break;
if ((int)c + n > 122) c = (char)((int)c - 26 + n);
else c = (char)((int)c + n);
s.push_back(c);
}
cout << s ;
return 0;
}