kojoker @ 2017-09-23 17:48:05
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int n,i=0;
char a[26];
cin>>n>>a;
while(a[i]!='\0')
{
a[i]+=n;
if(a[i]>122)
a[i]-=26;
++i;
}
i=0;
while(a[i]!='\0')
{
cout<<a[i];
i++;
}
return 0;
}
by 天下第一! @ 2017-09-23 18:14:03
为什么要定义一个字符串?定义一个数组好做一些呀
by 治涨的馒头 @ 2017-09-24 01:43:20
用string类型
by 治涨的馒头 @ 2017-09-24 01:44:19
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string a;
cin>>n>>a;
for(int i = 0;i < a.size();i++)
{
a[i]+=n;
while(a[i] > 122)
a[i] -= 26;
}
cout<<a;
return 0;
}
为毛60啊