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

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); 
}

郎朗坤
浏览 148回答 2
2回答

慕婉清6462132

#include <stdio.h>&nbsp;#include<string.h>void fun (char *s)&nbsp;{&nbsp;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';}&nbsp;void main( )&nbsp;{ char s[80];&nbsp;printf("\n Enter a string with length < 80. :\n\n "); gets(s);&nbsp;printf("\n The string : \n\n ");&nbsp;&nbsp;puts(s);&nbsp;fun ( s );&nbsp;printf ("\n\n The Cords :\n\n ");&nbsp;&nbsp;puts(s);&nbsp;}

哆啦的时光机

void fun (char *s)&nbsp;{ 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;}
打开App,查看更多内容
随时随地看视频慕课网APP