qaz12345678_ @ 2024-07-21 17:32:28
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin >> n;
cin >> s;
for (int i = 1;i <= s.size();i++)
{
s[i] += n;
if (s[i] > 'z')
{
s[i] -= 'z';
s[i] += 'a';
}
}
cout << s;
return 0;
}
by fire_flies @ 2024-07-21 17:33:28
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
cin>>n>>s;
for(int i=0;s[i]!='\0';i++){
putchar((s[i]-'a'+n)%26+'a');
}
return 0;
}
@qaz12345678_
by yukimianyan @ 2024-07-21 17:40:29
@qaz12345678_ string 下标从 0 开始
by Lrhnb @ 2024-07-21 17:57:12
今天刚考这题
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
string a;
cin>>n>>a;
for(int i=0;i<n;i++){
for(int j=0;j<a.size();j++){
if(a[j]=='z'){
a[j]='a';
}else{
a[j]+=1;
}
}
}
cout<<a;
return 0;
}
by yangqingyun @ 2024-07-21 18:03:04
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin >> n;
cin >> s;
for (int i = 0;i < s.size();i++)
{
if(s[i]+n>'z')
{
s[i]-=26;
}
s[i]+=n;
}
cout << s;
return 0;
}
by WXY_ShiXiaoJi @ 2024-08-01 16:49:41
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
cin>>s;
int len=s.length();
for(int i=0;i<len;i++){
if(s[i]>='a' && s[i]<='z'){
s[i]=s[i]-'a'+'A';
}
}
cout<<s;
return 0;
}
by fmg93 @ 2024-08-30 09:00:35
答案来