Silber @ 2022-10-14 23:24:02
#include <stdio.h>
int main()
{
char a[51] = {0};
int n;
scanf("%d", &n);
n %= 26;
getchar();
gets(a);
for (int cnt = 0; a[cnt] != 0; cnt++)
{
if (a[cnt] - 'a' + n >= 26)
{
a[cnt] -= 26;
}
a[cnt] += n;
}
puts(a);
return 0;
}
by ZHR20100222 @ 2022-10-14 23:32:01
@Silber
自己找找问题吧:
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int t,n,i;
char a[5000];
int main(){
scanf("%d",&t);
scanf("%s",a);
n=strlen(a);
for(i=0;i<=n-1;i++){
for(int j=1;j<=t;j++){
a[i]++;
if(a[i]>'z'){
a[i]='a';
}
}
}
printf("%s",a);
return 0;
}