题目内容:
下列给定程序中,函数fun()的功能是:将str所指字符串中的字母转换为按字母序列的后续字母(Z转换A,z转换a),其他字符不变。请修改函数fun()中的错误,得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
void fun(char*str)
{
//****found****
while(*str!='@')
{
if(*str>='A'&&*str<='Z'||*str<='
a'&&*str<='2')
{
if(*str=='Z ')
else if(*str=='z')
*str='a';
else
*str+=1:
}
//****found****
(*str)++:
}
}
void main()
{
char str[80];
printf("\n Enter a string with length<80.:\n\n");
gets(str);printf("\n The string:\n\n");
puts(str);
fun(str);
printf("\nln The Cords:\n\n");
puts(str);
}
参考答案:【答案仅供学习,请勿对照自行用药等】
答案解析: