/*
字符串的简单加密:
对给定的字符串,把其中从a~y,A~Y的字母用其后续字母替代,把z和Z分别用字母a和A替代
*/
#include <stdio.h>
#include <string.h>
int main(void)
{
char text[80];
int len;
printf("请输入要加密的字符串:\n");
gets(text);//字符串含有空格字符,则要用 string.h的gets()函数
len=strlen(text);
for(int i=0;i<len;i++)//遍历字符串进行加密处理
{
if(text[i]>='a'&&text[i]<'z'||text[i]>='A'&&text[i]<'Z')
{
text[i]++;//字符变量自加1,更小为按ASCII码往后+1的值
}
else if(text[i]=='z')
{
text[i]='a';
}
else if(text[i]='Z')
{
text[i]='A';
}
}
printf("加密后的字符串为:\n%s",text);
return 0;
}输出: