题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-23 14:01:10

[填空题]下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构. 试题程序: #include <conio.h> #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) /**************found**************/ if(*r==*p) {r++; p++} else break; /*************found**************/ if(r==’/0’) n++; s++; } return n; } main( ) {char s[100], t[100]; int m; clrscr( ); 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); }

更多"下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指"的相关试题:

[填空题]下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <conio.h>
#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)
/**************found**************/
if(*r==*p) r++; p++
else break;
/*************found**************/
if(r==’/0’)
n++;
s++;

return n;

main( )
char s[100], t[100]; int m;
clrscr( );
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);

[填空题]下列给定程序中,函数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);

[填空题]下列给定的程序中,函数fun( )的功能是;将s所指字符串中出现的n所指字符串全部替换成t2所指字符串,所形成的新的字符串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。例如:当s所指字符串中所指的内容为 abcdabfab,t1所指字符串中的内容为ab,t2所指字符串中的内容为99时,结果在w所指的数组中的内容应为99cd99f99。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
int fun (char *s, char *t1, char *t2, char *w)

int i; char *p,*r,*a;
strcpy(w,s);
while (*w)
p=w; r=t1;
/*************found**************/
while (r)
if (*r= =*p) r++;p++;
else break;
if (*r= =’/0’)
a=w; r=t2;
/*************found**************/
while (*r)*a=*r;a++;r++
w+=strlen(t2);

else w++;

main( )
char s[100],t1[100],t2[100],w[100];
clrscr( );
printf("/nPlease enter string S: ");
scanf("%s",s);

[简答题]下列给定程序中,函数fun的功能是:求出s所指字符串中最后一次出现的t所指字符串的地址,并通过函数值返回,在主函数中输出从此地址开始的字符串;若未找到,则函数值为NULL。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动mam函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
char *fun(char *s, char *t)
char*p,*r, *a;
/******************found*******************/
a=Null;
while(*s)
p=s; r=t;
while(*r)
/******************found*******************/
if(r==p)r++; p++;
else break;
if(*r==’/0’)a=s;
s++;

return a;

void main( )
char s[100], t[100], *p;
printf("/nPlease enter string S:");
scanf("%s", s);
printf("/nPlease enter substring t:");
scanf("%s", t);
p=fun(s, t);
if(p)
printf("/nThe result is:%s/n", p);
else
printf("/nNot found!/n");

[填空题]给定程序MODI1.C中函数fun的功能是:求出s所指字符串中最后一次出现的t所指字符串的地址,通过函数值返回,在主函数中输出从此地址开始的字符串。若未找到,则函数的返回值为NULL。例如,字符串s中的内容为“abcdabfabcdx”,若t中的内容为“ah”时,则输出结果为:abcdx;若t中的内容为“abd”,则程序输出未找到的信息:not be found!。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<string.h>
char *fun(char *s,char *t)
char *p,*r,*a;
/**********found**********/
a=NUll;
while(*s)
p=s;r=t;
while(*r)
/**********found**********/
if(r==P)r++;p++;
else break;
if(*r==’/0’)a=s;
s++:

return a;

void main( )
char s[100],t[100],*p;
printf("/nPlease enter string s: ");
scanf("%s",s);
printf("/nPlease enter string t: ");
scanf("%s",t);
p=fun(s,t);
if(P)printf("/nTbe result is: %s/n",p);
else printf("/nNot found!/n");

[简答题]给定程序MODI1.C中函数fun( )的功能是:求出s所指字符串中最后一次出现t所指子字符串的地址,通过函数值返回,在主函数中输出从此地址开始的字符串;若未找到,则函数值为NULL。
例如,当字符串中的内容为”abcdabfabcdx”,t中的内容为”ab”时,输出结果应是abcdx。当字符串中的内容为”abcdabfabcdx”,t中的内容为”abd”时,则程序输出未找到信息not be found!。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main( )函数,不得增行或删行,也不得更改程序的结构。
#include <stdio.h>
#include <string.h>
char *fun(char *s, char *t)

char *p, *r, *a;
/**********found**********/
a=Null;
while (*s)
p=s;r=t;
while (*r)
/**********found**********/
if (r==p)
r++;p++;
else break;
if (*r==’/0’)a=s;
s++;

return a;

main( )

char s[100], t[100], *p;
printf("/nPlease enter string S:"); scanf(%s",s);
printf("/nPlease enter substring t:"); scanf("%s",t);
p=fun(s,t);
if(p) printf(/nThe result is:%sha",p);
else printf("/nNot found !/a");

[填空题]给定程序中,函数fun( )的功能是统计形参s所指字符串中数字字符出现的次数,并存放在形参t所指的变量中,最后在主函数中输出。例如,形参s所指的字符串为abcdef35adgh3kjsdf7,输出结果为4。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
#include<stdio.h>
void fun(char *s,int *t)
int i,n;
n=0;
/**********found**********/
for(i=0; (1) !=0;i++)
/**********found**********/
if(s[i]>=’0’&&s[i]<= (2) )n++;
/**********found**********/
(3) ;

main( )
char s[80]="abcdef35adgh3kjsdf7";
int t;
printf("/nThe original string is:%s/n",s);
fun(s,&t);
printf("/nThe result is:%d/n",t);

[填空题]给定程序中,函数fun的功能是:将形参s所指字符串中的所有数字字符顺序前移,其他字符顺序后移,处理后新字符串的首地址作为函数值返回。
例如,s所指字符串为:asdl23fgh5##43df,
处理后新字符串为:123543asdfgh##df。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的行线上填入所编写的若干表达式或语句。
[试题源程序]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
char*fun(Char*s)

int i,j,k,n;char *p,*t;
n=strlen(s)+1;
t=(char*)malloc(n*sizeof(char));
p=(char*)malloc(n*sizeof(char));
j=0;k=0;
for(i=0;i<n;i++)

if(isdigit(s[i]))

/**********found**********/
p[ (1) ]=s[i];j++;

else

t[k]=s[i];k++;


A*********found**********/
for(i=0;i< (2) ;i++)p[j+i]=t[i];
p[j+k]=0;
/**********found**********/
return (3)

main( )

char s[80];
printf("Please input:");scanf("%s",s);
printf("/nThe result is: %s/n",fun(s));

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码