114514_coding @ 2023-07-21 14:39:13
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
char n;cin>>n;
char a[55];
scanf("%s",a);
for(int i=0;i<strlen(a);i++)
{
if(a[i]=='z')
{
a[i]='a'+n-'1';
cout<<a[i];
}
else
{
a[i]+=n-'0';
cout<<a[i];
}
}
return 0;
}
by 114514_coding @ 2023-07-21 14:40:48
刚学字符数组不怎么懂,我试了一下好像没问题啊,但就60分
by Happy_Doggie @ 2023-07-21 14:41:03
n 不一定只等于一啊
by Happy_Doggie @ 2023-07-21 14:41:58
2
yyy
{{{
by Lieyiqi @ 2023-07-21 14:43:07
感觉大佬代码好长,其实用putchar可以很快解决
by Happy_Doggie @ 2023-07-21 14:43:24
这要是特判就累死了,也不是不行
by 114514_coding @ 2023-07-21 14:44:08
@YGW6 谢
by YGW6 @ 2023-07-21 14:47:46
@114514_coding
嗯,看来我之前不是很老实呢
应该是在很久之前打的,当时多半不会,看了题解
所以那应该是出自 仇哥 的题解,但是我自己打的
by YGW6 @ 2023-07-21 14:49:38
改于 仇哥 的题解(应该是)
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin>>n;
cin>>s;
for(int i=0;i<=s.size()-1;i++)
cout<<char((s[i]-'a'+n)%26+'a');
return 0;
}
by 114514_coding @ 2023-07-21 14:57:19
感谢各位大佬哈
我改了亿点点过了
( 虽然代码有亿点长)
#include<bits/stdc++.h>
using namespace std;
int main()
{
char str[55];
int n;scanf("%d%s",&n,str);
n=n%26;
for(int i=0;str[i]!='\0';i++)
{
if(str[i]+n>'z')
{
str[i]+=n+'a'-'z'-1;
cout<<str[i];
}
else
{
str[i]+=n;
cout<<str[i];
}
}
return 0;
}