逆袭疾风 @ 2020-04-27 17:04:39
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
string password;
string newpass;
int n;
cin >> n; getchar();
getline(cin, password);
for (int i = 0; i < password.size(); i++) {
for (int j = 0; j < n; j++) {
if (password[i] < 'z') password[i]++;
if(password[i]=='z') password[i] = password[i]-25;
}
}
newpass = password;
cout << newpass;
return 0;
}
ps:getchar加不加都报错
by MilkyCoffee @ 2020-04-27 17:05:20
你...
by a1co0av5ce5az1cz0ap_ @ 2020-04-27 17:05:53
为啥要getchar
by MilkyCoffee @ 2020-04-27 17:06:17
窝的代码,仅供参考,如果抄袭,怒不奉陪!
// #include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
int main() {
string s;
cin >> n;
cin >> s;
int len = s.length();
for (int i = 0; i < len; i++) {
for (int j = 1; j <= n; j++) {
s[i]++;
if (s[i] > 'z') s[i] = 'a';
}
}
cout << s << endl;
return 0;
}
by a1co0av5ce5az1cz0ap_ @ 2020-04-27 17:07:18
我也送一个:(码风不好)
#include<iostream>
using namespace std;
string s;
int n;
void zhh(){
int l=s.size();
for(int i=1;i<=n;i++){//要n次全体+1
for(int j=0;j<l;j++){//每次从头到尾都+1
s[j]++;
if(s[j]>'z') s[j]='a';
}
}
return ;
}
int main(){
cin>>n>>s;
zhh();
cout<<s<<endl;
return 0;
}
by Trinitrotoluene @ 2020-04-27 17:08:38
string password;
getline(cin, password);
以及
newpass = password;
cout << newpass;
是什么鬼?
by a1co0av5ce5az1cz0ap_ @ 2020-04-27 17:10:46
哈哈哈。。。
by Uim_ @ 2020-08-06 15:29:21
同问,我也是这样的qwq
#include <bits/stdc++.h>
using namespace std;
int n;
char a[50];
int main(){
scanf("%d",&n);
getchar();gets(a);
for(int i=0;i<strlen(a);i++){
if(a[i]+n>122) a[i]=a[i]+n-26;
else a[i]=a[i]+n;
printf("%c",a[i]);
}
return 0;
}