问答题
函数fun()的功能是:将s所指字符串中的字母转换为按字母序列排列的其后续字母(注:Z转换为A,z转换为a),其他字符不变。
改正函数fun()中指定部分的错误,使它能得出正确的结果。
#include<stdio.h>
#include<ctype.h>
void fun(char *s)
/**********found**********/
while(*s!=’@’)
if(*s>=’A’&&*s<=’Z’||*s>=’a’&&*s<=’z’)
if(*s==’Z’)*s=’A’;
else if(*s==’Z’)*s=’a’;
else *s+=1;
/**********found**********/
(*s)++;
main()
char s[80];
printf("\n Enter a string with length<80.:\n\n");gets(s);
print"\n The string:\n\n");puts(s);
fun(s);
printf("\n\n The Cords:\n\n");puts(s);
【参考答案】
(1)while(*s)或while(*s!=’\0’)或while(*s!=0); (2)s++;
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
问答题
函数fun()的功能是:从s所指字符串中,找出与t所指字符串相同的子串的个数作为函数值返回。例如,当s所指字符串中的内容为”abcdabfab”,t所指字符串的内容为”ab”,则函数返回整数3。 请改正程序中的错误,使它能得出正确的结果。 #include <stdio.h> #include <string.h> int fun(char *s,char *t) int n;char *p,*r; n=0; while(*s) p=s;r=t; while(*r) if(*r==*p) **********found********** r++;p++ else break; **********found********** if(r==’ 0’) n++; s++; return n; main() char s[100],t[100];int m; printf( nPlease enter string S: );scanf( %s ,s); printf( nPlease enter substring t: );scanf( %s ,t); m=fun(s,t); printf( nThe result is:m=%d n ,m);
点击查看答案&解析
问答题
给定程序MODI1.C中函数fun()的功能是按以下递归公式求函数值。 例如,当给n输入5时,函数值为18;当给n输入3时,函数值为14。 请改正程序中的错误,使它能得出正确结果。 #include<stdio.h> **********found********** int fun(n) int c; **********found********** if(n=1) c=10; else c=fun(n-1)+2; return(c); main() int n; printf( Enter n: );scanf( %d ,&n); printf( The result:%d n n ,fun(n));
点击查看答案&解析
相关试题
编写函数fun(),其功能是将放在字符数组...
编写函数fun(),其功能是从s所指的字符串...
编写函数fun(),其功能是将M行、N列的二...
给定程序MODI1.C中函数fun()的功能是:...
请编写一个函数fun(),其功能是比较两个...