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