如何用c语言编:输入一字符串,将其中所有的大写英文字母+3,小写英文字母-3,然后再输出加密后的字符串

来源:百度知道 编辑:UC知道 时间:2024/04/27 02:56:29

#include<stdio.h>
main(){
char s[]={""};
int i;
gets(s);
for (i=0;s[i]!='\0';i++){
if (s[i]>='a' && s[i]<='z'){
s[i]-=3;
}else if(s[i]>='A' && s[i]<='Z'){
s[i]+=3;
}
}
puts(s);
}

#include<stdio.h>
int main(){
int i,len;
char st[100];
printf("please input a string\n");
scanf("%s",st);
printf("加密前:\n%s\n" , st);
for(i = 0 ; st[i] ; i++){
if ( st[i] >= 'a' && st[i] <= 'z')
st[i] -= 3;
else if (st[i] >= 'A' && st[i] <= 'Z')
st[i] += 3;
}
printf("加密后:\n%s\n" , st);
fflush(stdin);
getch();

}

#include <stdio.h>
main()
{
char c,b;
printf("请输入字符:\n");
while((c