题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-12-19 07:50:56

[填空题]下列给定程序中,函数fun( )的功能是:从字符串s中,删除所有小写字母’c’。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构. 试题程序: # include <stdio.h> void fun(char *s) {int i, j; for(i=j=0; s[i] != ’/0’;i++) if(sill != ’c’) /********************************/ s [j] =s [i]; /**************found*************/ s[i]=’/0’; } main ( ) { char s[80]; printf ("/nEnter a string: "); gets (s); printf("The original string: ") puts (s); fun (s); printf("The string after deleted: "); puts (s); printf ("/n/n "): }

更多"下列给定程序中,函数fun( )的功能是:从字符串s中,删除所有小写字"的相关试题:

[填空题]下列给定程序中,函数fun( )的功能是:从字符串s中,删除所有小写字母’c’。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构.
试题程序:
# include <stdio.h>
void fun(char *s)
int i, j;
for(i=j=0; s[i] != ’/0’;i++)
if(sill != ’c’)
/********************************/
s [j] =s [i];
/**************found*************/
s[i]=’/0’;

main ( )
char s[80];
printf ("/nEnter a string: ");
gets (s);
printf("The original string: ")
puts (s);
fun (s);
printf("The string after deleted: ");
puts (s); printf ("/n/n "):

[填空题]以下程序的功能是将字符串s中所有小写字母’a’删去,请填空。
#include<stdio.h>
main( )
char s[]="absuWWUDJFKFLaaakdK";
int i,j;
for(i=j=0;s[i]!=’/0’;i++)
if( )
s[j++]=s[i];
s[j]=’/0’;
printf("%s",s);

[简答题]给定程序MODI1.C中fun( )函数的功能是:将n个无序整数从小到大排序。
请改正程序中的错误,使它能得出正确的结果。
#include<stdio.h>
#include<stdlib.h>
fun(int n,int *a)
int i,j,p,t;
for(j=0;j<n-1;j++)
p=j;
/**********found**********/
for(i=j+1;i<n-1;i++)
if(a[p]>a[i])
/**********found**********/
t=i;
if(p!=j)
t=a[j];a[j]=a[p];a[p]=t;)


putarr(int n,int *z)
int i;
for(i=1;i<= n;i++,z++)
printf("%4d",*z);
if(!(i%10))printf("/n");
printf("/n");

main( )
int aa[20]=(9,3,0,4,1,2,5,6,8,
10,7,n=11;
printf("/n/nBefore sorting %d numbers:/q",n);putarr(n,aa);
fun(n,aa);
printf("/nAfter sorting %d numbers:/n",n);putarr(n,aa);

[填空题]下列给定程序中fun( )函数的功能是:将n个无序整数从小到大排序。
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
fun(int n, int *a)
int i,j,p,t;
for (j=0;j<n-1;j++)
P=j;
/***************found*******************/
for(i=j+l;i<n-1;i++)
if (a[p]>a[i])
/***************found*******************/
t=i;
if (p!=j)
t=a[j];a[j]=a[p];a[p]=t;


putarr( iht n,int *z)
int i;
for (i=l;i<=n;i++,z++)
printf("%4d",*z);
if (!(i%10)) printf("/n");
printf ("/n");

main ( )
int aa[20]=9,3,0,4,1,2,5,6,8,10,7,n=11;
clrscr( );
printf("/n/nBefore sorting %d numbers:/n",n); putarr(n,aa);
fun(n,aa);
printf("/nAfter sorting %d numbers:/n",n);putarr(n,aa);

[填空题]下列给定程序中,函数fun( )的功能是:计算整数n的阶乘。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <stdio.h> double fun(int n) { double result=l.0; whil (n>l&&n<170) /**************found********************/ result*=--n; /**************found********************/ return; main( ) {int. n; clrscr( ); printf("Enter an integer: "); scanf("%d",&n); printf("/n/n%d!=%lg/n/n ",n, fun(n)); }
[简答题]下列给定程序中,函数fun的功能是:计算整数n的阶乘。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdlib.h>
#include <stdio.h>
double fun(int n)
double result=1.0;
while(n>1&&n<170)
/******************found*******************/
result*=--n;
/******************found*******************/
Return;

void main( )
int n;
system("CLS");
printf("Enter an integer:");
scanf("%d", &n);
printf("/n/n%d!=%1dn/n", n, fun(n));

[填空题]下列给定程序中,函数fun( )的功能是:从字符串s中,删除所有大写字母’F’。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
void fun(char *s)

int i, j;
/*************found**************/
for(i=j=0; s[i]!= ’0’;i++)
if(s[i] != ’F’)
/*************found**************/
s[j]=s[i];
s[j]=’/0’;

main ( )

char s[80];
printf("/nEnter a string: ");
gets(s);
printf("The original string: ");
puts(s);
fun(s);
printf("The string after deleted: ");
puts(s);
printf("/n/n ");

[简答题]下列给定程序中,函数fun的功能是:用冒泡法对6个字符串按由小到大的顺序排列。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#define MAXLINE 20
fun(char*pstr[6])

lnt i,j;
char *p;
for(i=O;i<5;i++)

/********found********/
for(j=i+l,j<6,j++)

if(strcmp(*(pstr+i)*(pstr+j))>0)

P=*(psfr+i);
/********found********/
*(pstr+i)=pstr+j;
*(pstr+j)=p;




void main( )

int i;
char*pstr[6],str[6][MAXLINE];
system("CLS");
for(i=O;i<6;i++)
pstr[i]=str[i];
printf("/nEnter 6 string(1 string at eachline):/n");
for(i=0;i<6;i++)
scanf("%s",pstr[i]);
fun(pstr);
printf("The strings after sorting:/n");
for(i=O;i<6;i++)
printf("%s/n"pstr[i]);

[填空题]给定程序中,函数fun( )的功能是:使数组中的元素的值缩小5倍。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdio.h> #include<conio.h> float m[10]; /*************found**************/ int fun (void) { int j; printf("In subfunc after calling/n"); for(j=O;j<lO;j++) { ; /*************found**************/ print ("%f ",m[j]%5); } } main( ) { int i; printf ("In main before calling/n"); for (i=0;i<10;i++) { m[i]=i+20; printf("%f ",m[i]); } fun( ); printf("/nIn main after calling/n"); for(i=O; i<10;i++) printf("%f ",m[i]/5); }
[填空题]给定程序中,函数fun( )的功能是:使数组中的元素的值缩小5倍。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<conio.h>
float m[10];
/*************found**************/
int fun (void)

int j;
printf("In subfunc after calling/n");
for(j=O;j<lO;j++)
;
/*************found**************/
print ("%f ",m[j]%5);


main( )

int i;
printf ("In main before calling/n");
for (i=0;i<10;i++)

m[i]=i+20;
printf("%f ",m[i]);

fun( );
printf("/nIn main after calling/n");
for(i=O; i<10;i++)
printf("%f ",m[i]/5);

[填空题]下列给定程序中,函数fun( )的功能是:用冒泡法对6个字符串按由小到大的顺序进行排序。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构. 试题程序: #include <conio.h> #include <stdio.h> #define MAXLINE 20 /*************found**************/ fun(char *pstr[6]) {int i, j; char *p; for(i=0;i<5;i++) {for(j=i+l;j<6;j++) /*************found**************/ { if(strcmp(*(pstr+i),pstr+j)>0) { p=*(pstr+i); /*************found**************/ * (pstr+i) -pstr+j; * (pstr+j)=p; } } } } main ( ) { int i; char *pstr[6],str[6][MAXLINE]; clrscr( ); for(i=0;i<6;i++) pstr[i]=str[i]; printf("/nEnter 6 string(1 string at each line):/n "); for(i=0;i<6;i++) scanf("%s",pstr[i]); fun(pstr); printf("The strings after sorting:/n "); for(i=0;i<6;i++) printf("%s/n ",pstr[i]); }
[填空题]下列给定程序中,函数fun( )的功能是:用冒泡法对6个字符串按由大到小的顺序进行排序。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> #define MAXLINE 20 void fun(char *pstr[6]) { int i,j; char *p; for(i=0;i<5;i++) for(j=i+1;j<6;j++) /*************found*************/ if(strcmp((pstr+i),(pstr+j))<0) { p=*(pstr+i); *(pstr+i)=*(pstr+j); /*************found*************/ *(pstr+j)=*p; } } main( ) { int i; char*pstr[6],str[6][MAXLINE]; clrscr( ); for(i=0;i<6;i++) pstr[i]=str[i]; printf("/nEnter 6 string(1 string at each line):/n"); for(i=0;i<6;i++) scanf("%s",pstr[i]); fun(pstr); printf("The strings after sorting:/n"); for(i=0;i<6;i++) printf("%s/n",pstr[i]); }
[填空题]下列给定程序中,函数fun( )的功能是:用冒泡法对6个字符串按由大到小的顺序进行排序。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#define MAXLINE 20
void fun(char *pstr[6])

int i,j;
char *p;
for(i=0;i<5;i++)
for(j=i+1;j<6;j++)
/*************found*************/
if(strcmp((pstr+i),(pstr+j))<0)

p=*(pstr+i);
*(pstr+i)=*(pstr+j);
/*************found*************/
*(pstr+j)=*p;


main( )

int i;
char*pstr[6],str[6][MAXLINE];
clrscr( );
for(i=0;i<6;i++)
pstr[i]=str[i];
printf("/nEnter 6 string(1 string at each line):/n");
for(i=0;i<6;i++)
scanf("%s",pstr[i]);
fun(pstr);
printf("The strings after sorting:/n");
for(i=0;i<6;i++)
printf("%s/n",pstr[i]);

[填空题]由N个有序整数组成的数列已放在一维数组中,下列给定程序函数fun的功能是:利用折半查找法查找整数m在数组中的位置。若找到,返回其下标值;否则,返回-1。
折半查找的基本算法是:每次查找前先确定数组中待查的范围low和high(low<high),然后用m与中间位置(mid)上元素的值进行比较。如果m的值大于中间位置元素的值,则下一次的查找范围落在中间位置之后的元素中;反之,下一次的查找范围落在中间位置之前的元素中,直到low>high,查找结束。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 10
/**********found**********/
void fun(int a[],int m)
int low=0,high=N-1,mid;
while(low<=high)
mid=(low+high)/2;
if(m<a[mid])
high=mid-1;
/********found**********/
else if(m>a[mid])
low=mid+1;
else return(mid);

return(-1);

void main( )
int i,a[N]=(-3,4,7,9,13,45,67,89,100,180),
k,m;
printf("a数组中的数据如下:");
for(i=0;i<N;i++)
printf("%d",a[i]);
printf("Enter m:");
scanf("%d",&m);
k=fun(a,m);
if(k>=0)
printf("m=%d,index=%d/n",m,k);
else printf("Not be found /n");

[简答题]下列给定程序中,函数fun( )的功能是计算并输出high以内的素数之和。high由主函数传给fun( )函数。
例如:若high的值为100,则函数的返回值为1060。
请改正程序中的错误,使它能得到正确结果。
[注意] 不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include <conio.h>
#include <stdio.h>
#include<math.h>
int fun(int high)

int sum=0, n=0, j, yes;
while(high>=2)

yes=1;
for(j=2;j<=high/2; j++)
**********************found**********************/
ifhigh%j==0

yes=0;
break;

/**********************found**********************/
if(yes==0)

sum+=high;
n++;

high--;

return sum;

main( )

clrscr( );
printf("%d/n", fun(100));

我来回答:

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

订单号:

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