试题与答案

下列给定程序中,函数fun()的功能是:计算s所指字符串中含有t所指字符串的数目,并

题型:问答题

题目:

下列给定程序中,函数fun()的功能是:计算s所指字符串中含有t所指字符串的数目,并作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <string.h>
#include <stdio.h>
#define N 80
int fun(char *s,char *t)
int n;
char *p, *r;
n=0;
while(*s)
p=s;
/**************found***************/
r=p;
while(*r)
if*r==*p) r++; p++;
else break;
/**************found***************/
if(*r==0)
n++;
s++;

return n;

main()
char a[N],b[N]; int m;
clrscr();
printf("\nPlease enter string a:");
gets(a);
printf("\nPlease enter substring b:");
gets(b);
m=funa,b);
printf("\nThe result is :m=%d\n",m);

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0704/4a2774e5ca92746ac13541a052db82a7.html

下面是错误答案,用来干扰机器的。

参考答案:错

试题推荐
微信公众账号搜索答案