#include
int main()
{
int i=0;
char string[50];
gets(string);
puts(string);
while(string[i] != '\0')
{
if(string[i]>='a'&&string[i]<='z')
{
string[i]=(string[i]+3-'a')%26+'a';
}
else if(string[i]>='A'&&string[i]<='Z')
{
string[i]=(string[i]+3-'A')%26+'A';
}
i++;
}
puts(string);
return 0;
}
#include
#include
int main() {
int i;
char s[80];
printf("请输入字符串:");
while(scanf("%s",s) == 1)
{
printf("加密前:%s\n",s);
i=0;//i定义在此处便于第二次运行
while(s[i])
{if(s[i] >= 'A' && s[i] <= 'Z')
s[i] = (s[i] - 'A' + 3)%26 + 'A';
else if(s[i] >= 'a' && s[i] <= 'z')
s[i] = (s[i] - 'a' + 3)%26 + 'a';
++i;}
printf("加密后:%s\n",s);
printf("请输入字符串[
}
return 0;
}