为了账号安全,请及时绑定邮箱和手机立即绑定

a转换为b, b转换为c, z转换为a,大写字母规律相同,其它字符不变

a转换为b, b转换为c, z转换为a,大写字母规律相同,其它字符不变

郎朗坤 2023-04-22 22:18:18
13. 函数fun的功能是: 将s所指字符串中的字母转换为按字母序列的后续字母,其它字符不变。 给定源程序: #include <stdio.h> void fun (char *s) { } void main( ) { char s[80]; printf("\n Enter a string with length < 80. :\n\n "); gets(s); printf("\n The string : \n\n "); puts(s); fun ( s ); printf ("\n\n The Cords :\n\n "); puts(s); }
查看完整描述

2 回答

?
慕婉清6462132

TA贡献1804条经验 获得超2个赞

#include <stdio.h> 
#include<string.h>
void fun (char *s) 

int i,l;
l=strlen(s);
for(i=0;i<l;i++)
if(s[i]>='a'&&s[i]<'z'||s[i]>='A'&&s[i]<'Z')
s[i]=s[i]+1;
else if(s[i]=='z')
s[i]='a';
else if(s[i]=='Z')
s[i]='A';


void main( ) 
{ char s[80]; 
printf("\n Enter a string with length < 80. :\n\n "); gets(s); 
printf("\n The string : \n\n ");  
puts(s); 
fun ( s ); 
printf ("\n\n The Cords :\n\n ");  
puts(s); 
}


查看完整回答
反对 回复 2023-04-25
?
哆啦的时光机

TA贡献1779条经验 获得超6个赞

void fun (char *s) 
{ int i;
for(i=0;s[i]!='\0';i++)
if(s[i]=='z'||s[i]=='z')s[i]='a';else if(s[i]>='a'&&s[i]<='z')s[i]=s[i]+1;else if(s[i]>='A'&&s[i]<='Z')s[i]=s[i]+1;

}

查看完整回答
反对 回复 2023-04-25
  • 2 回答
  • 0 关注
  • 97 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信