题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-13 01:24:08

[填空题]下列给定的程序中,函数fun( )的功能是:判断字符ch是否与str所指字符串中的某个字符相同;若相同,则什么也不做,若相同,则将其插在申的最后。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> #include <string.h> /*************found**************/ void fun (char str,char ch) {while (*str &&*str !=ch) str++; /*************found**************/ if(*str==ch) { str[0]=ch; /*************found**************/ str[1]=’0’; } } main( ) {char s[81],c; clrscr( ); printf("/nPlease enter a strzng : "); gets(s); printf("/n Please enter the character to search : "); c=getchar( ); fun(s,c); printf("/nThe result is %s/n",s); }

更多"下列给定的程序中,函数fun( )的功能是:判断字符ch是否与str所"的相关试题:

[填空题]下列给定程序中,函数fun( )的功能是:在字符串str中找出ASCII码值最小的字符,将其放在第一个位置上,并将该字符前的原字符向后顺序移动。例如,调用fun( )函数之前给字符串输入fagAgBDh,调用后宁符串中的内容为AfaggBDh。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdio.h> /*************found************/ void fun(char p) { char min,*q; int i=0; min=p[i]; while (p[i]!=0) { if (min>p[i]) { /*************found*************/ p=q+i; min=p[i]; } i++; } while(q>p) {*q=*(q-1); q--; } p[0]=min; } main( ) { char str[80]; printf("Enter a string:"); gets(str); printf("/nThe original string:"); puts(str); fun(str); printf("/nThe string after moving:"); puts(str); printf("/n/n"); }
[填空题]下列给定的程序中,函数fun( )的功能是:判断字符ch是否与str所指字符串中的某个字符相同;若相同,则什么也不做,若相同,则将其插在申的最后。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
void fun (char str,char ch)
while (*str &&*str !=ch) str++;
/*************found**************/
if(*str==ch)
str[0]=ch;
/*************found**************/
str[1]=’0’;


main( )
char s[81],c;
clrscr( );
printf("/nPlease enter a strzng : ");
gets(s);
printf("/n Please enter the character to
search : ");
c=getchar( );
fun(s,c);
printf("/nThe result is %s/n",s);

[填空题]下列给定程序中,函数fun( )的功能是:在字符串str中找出ASCII码值最大的字符,将其放在第一个位置上,并将该字符前的原字符向后顺序移动。例如,调用fun( )函数之前给字符串输入ABCDeFGH,调用后字符串中的内容为 eABCDFGH。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
/***************found************/
fun(char *p)
char max, *q;int i=0;
max=p[i];
while (p[i]!=0)
if (max<p[i])

/***************found************/
p = q +i;max=p[i];

i++;

/***************found************/
while (q<p)
*q=*(q-1);
q--;

p[0]=max;

main( )
char str[80];
printf("Enter a string: "); gets(str);
printf("/nThe original string: ");
puts(str);
fun(str);
printf("/nThe string after moving: ");
puts(str); printf("/n/n");

[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)

int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】
*(p1+i)=’/0’;
main( )

char str1[N],str2[N);
clrscr( );
printf("*****Input the string str1 & str2*****/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("**The string str1 & str2**/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*****The new string *****/n");
puts(str1);

[填空题]给定程序中,函数fun的功能是:求出形参ss所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中共有M个字符串,且串长小于N。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
#defineM 5
#defineN 20
void fun (char (*ss)[N])
inti, j, k=0, n, m, len;
for(i=0; i<M; i++)
len=strlen(ss[i]);
if(i==0)n=len;
if (len>n)
/******************found*******************/
n=len; (1) =i;


for(i=0; i<M; i++)
if(if=k)
m=n;
len=strlen(ss[i]);
/******************found*******************/
for (j= (2) ; j>=0; j--)
ss[i][m--]=ss[i][j];
for (j=0; j<n-len; j++)
/******************found*******************/
(3) =’*’;


main( )
char ss[M][N]="shanghai", "guangzhou",
"beijing", "tianjin", "chongqing");
int i;
printf("/nThe original strings are:/n");
for(i=0; i<M; i++)
[填空题]在给定程序中,函数fun的功能是:求出形参SS所指字符串数组中最长字符串的长度,其余字符串左边用字符*补齐,使其与最长的字符串等长。字符串数组中共有M个字符串,且串长<N。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<string.h>
#define M 5
#define N 20
void fun(char( *ss)[N])
int i,j,k=0,n,m,len;
for(i=0;i<M;i++)
len=strlen(ss[i]);
if(i==0)n=len:
if(len>n)
/**********found**********/
n=len;
(1) =i;


for(i=0;i<M;i++)
if(i!=k)
m=n:
len=strlen(ss[i]);
/***********found***********/
for(j= (2) ;j>=0;j--)ss[i][m--]=ss[i][j];
for(j=0;j<n-len;j++)
/**********found**********/
(3) =’*’:

void main( )
char ss[M][N]="shanghai","guangzhou","beijing","tianjing","cchongqing";
int i;
printf("/nThe original strings are: /n");
for(i=0;i<M;i++)printf("%s/n",ss[i]);
printf("/n");
fun(ss);
printf("/nThe resuh
[填空题]下列给定程序中,函数fun( )的功能是:依次取出字符串中所有的字母,形成新的字符串,并取代原字符串。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<conio.h>
void fun(char*S)

int i,j;
for(i=0,j=0;s[i]! =’/0’;i++)
/*************found************/
if((s[i]>=’A’&&s[i]<=’Z’)&&(s[i]>= ’a’&&S[i]<=’z’,))
s[j++]=s[i];
/*************found*************/
s[j]="/0";

main( )

char item[80];
clrscr( );
printf("/nEnter a string:");
gets(item);
printf("/n/nThe string is:/%s/n",item);
fun (item);
printf("/n/nThe string of changing
is:/%S/n",item);

[简答题]下列给定程序中,函数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( )的功能是:将字符串p中所有字符复制到字符串b中,要求每复制3个字符之后插入一个空格。例如,在调用fun( )函数之前给字符串a输入ABCDEFGHIJK,调用函数之后,字符串b中的内容则为ABC DEF GHI JK。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio. h>
void fun (char *p, char *b)
int i, k=0;
while (*p)
/*************found***************/
i=l;
/*************found***************/
while (i<3|| *P)

b[k]=*p;
k++; p++; i++;

if (*p)
/*************found***************/
b[k]= ’ ’;

b[k]= ’/0’;

main ( )
char a[80],b[80];
printf ("Enter a string: "); gets (a);
printf ("The original string: ");
puts (a);
fun (a,b);
printf("/nThe string after insert
space: "); puts(b); printf("/n/n ");

[简答题]给定程序中,函数fun的功能是将参数给定的字符串、整数、浮点数写到文本文件中,再用字符串方式从此文本文件中逐个读入,并调用库函数atoi和atof将字符串转换成相应的整数、浮点数,然后将其显示在屏幕上。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include #include void fun(char *s, int a, double f) { /**********found**********/ __1__ fp; char str[100], str1[100], str2[100]; int a1; double f1; fp = fopen("file1.txt", "w"); fprintf(fp, "%s %d %f/n", s, a, f); /**********found**********/ __2__ ; fp = fopen("file1.txt", "r"); /**********found**********/ fscanf(__3__,"%s%s%s", str, str1, str2); fclose(fp); a1 = atoi(str1); f1 = atof(str2); printf("/nThe result :/n/n%s %d %f/n", str, a1, f1); } main( ) { char a[10]="Hello!"; int b=12345; double c= 98.76; fun(a,b,c); }
[填空题]下列给定程序中,函数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);

我来回答:

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

订单号:

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