题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-12-04 00:28:38

[填空题]下面程序的功能是将字符串s中的每个字符按升序的规则插到数组a中,字符串a已排好序。
#include<stdio.h>
#include<string.h>
void main( )
char a[20]="cehiknqtw";
char s[]="fbla";
int i,k,j;
for(k=0;s[k]!=’/0’;k++)
j=0;
while(s[k]>=a[j]&&a[j]!=’/0’)
j++;
for(______)
______;
a[j]=s[k];

puts(a);


更多"下面程序的功能是将字符串s中的每个字符按升序的规则插到数组a中,字符串"的相关试题:

[填空题]下面程序的功能是将字符串s中的每个字符按升序的规则插到数组a中,字符串a已排好序。
#include<stdio.h>
#include<string.h>
void main( )
char a[20]="cehiknqtw";
char s[]="fbla";
int i,k,j;
for(k=0;s[k]!=’/0’;k++)
j=0;
while(s[k]>=a[j]&&a[j]!=’/0’)
j++;
for(______)
______;
a[j]=s[k];

puts(a);


[简答题]给定程序中函数fun的功能是:首先把b所指字符串中的字符按逆序存放,然后将a所指字符串中的字符和b所指字符串中的字符,按排列的顺序交叉合并到c所指数组中,过长的剩余字符接在c所指的数组的尾部。例如,当a所指字符串中的内容为“abcdefg”,b所指字符串中的内容为“1234”时,c所指数组中的内容应“a4b3c2dlefg”;而当a所指字符串中的内容为“1234”,b所指字符串的内容为“abcdefg”时,c所指数组中的内容应该为“lg2f3e4dcba”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
void fun (char*a, char*, char *c)

inti, j; char ch;
i=0; j=strlen(b)-1;
/******************found*******************/
while(i>j)
ch=b[i]; b[i]=b[j]; b[j]=ch;
i++; j--;

while (*a|| *b)
/******************found*******************/
If(*a)
*c=*a; c++; a++;
if(*b)
*c=*b; c++; b++;

*c=0;

main( )

char s1[100], s2[100], t[200];
printf("/nEnter s1 string:"); scanf("%s", s1);
printf("/nEnter s2 string:"); scanf("%s", s2);
fun(s1, s2, t);
printf("/nThe result is: %s/n", t);

[填空题]下列给定程序中函数fun( )的功能是;先将在字符串s中的字符按逆序存放到t串中,然后把s中的字符按正序连接到t串的后面。例如:当s中的字符串为ABCDE时,则t中的字符串应为EDCBAABCDE。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
void fun (char *s, char *t )

int i,sl;
sl=strlen(s);
for (i=0;i<sl;i++)
t[i]=s[sl-1];
for (i=0; i<sl; i++)
/*************found**************
t [sl+i]=s [i];
t [2*sl]-’/0’;

main ( )
char s[100], t[100];
clrscr( );
printf("/nPlease enter string s: ");
scanf ("%s", s);
fun (s,t);
printf ("The result is: %s/n",t);

[填空题]以下程序的功能是:对输入的一行字符串的数字字符按它们的字面值累加,输出此累加和。例如,输入一行字符是:ab34dh8u,输出值应当是15。请填空。
#include <stdio.h>
#include <ctype.h>
main( )
char ch; int a,s;
【11】
while((ch=getchar( )) 【12】 )
if( isdigit (ch))
a= 【13】 ;s+=a;
printf("s=%d/n/n",s);
[填空题]下列给定程序中,函数fun( )的功能是:读入一个字符串 (长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。
例如:输入dafhc,则应输出hfdca。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,敢不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
/*************found**************/
int fun(char t[ ])

char c;
int i,j;
for(i=0;i<strlen(t)-1;i++)
for(j=i+1;i<strlen(t);j++)
if(t[i]<t[j])

c=t[j];
/*************found**************/
t[i]=t[i++];
t[i]=c;

main( )

char s[81];
clrscr( );
printf("/nPlease enter a character
string:");
gets(s);
printf("/n/nBefore sorting:/n%S",s);
fun(s);
printf("/nAfter sorting decendingly:/n
%s",s);

[填空题]下列给定程序中,函数fun( )的功能是:首先把b所指字符串中的字符按逆序存放,然后将a所指字符串中的字符和b所指字符串中的字符,按排列的顺序交叉合并到c所指数组中,过长的剩余字符接在c所指数组的尾部。例如,当a所指字符串中的内容为abcdefg,b所指字符串中的内容为1234时,c所指数组中的内容应该为a4b3c2dlefg;而当a所指字符串中的内容为1234,b所指字符串中的内容为abcdefg时,c所指数组中的内容应改为1g2f3e4dcba。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序 #include <conio.h> #include <stdio.h> #include <string.h> void fun(char *a, char *b, char *c) { int i, j; char ch; i=0; j=strlen(b)-1; /*************found**************/ while (i>j} {ch=bill; b[i]=b[j]; b[j]=ch; i++; j--; } while (*a||*b) { if (*a){*c=*a; c++; a++;} if(*b){*c=*b; c++; b++;} } /*************found**************/ *c=0 ; } main ( ) { char s1[100],s2[100],t[200]; clrscr( ); printf("/nEnter s1 string: "); scanf ("%s", s1); printf("/nEnter s2 string: "); scanf ("%s", s2); fun(s1,s2,t); printf("/nThe result is :%s/n",t); }
[填空题]下列给定程序中,函数fun( )的功能是:读人一个字符串(长度<20),将该字符串中的所有字符按ASCⅡ码降序排序后输出。 #include<stdio.h> void fun(char t[]) { char c; int i,j; for(i=0;______;i++)/*第一空*/ for(j=i+1;j<=strlen(t);j++) if(______)/*第二空*/ { c=t[j]; t[j]=t[i]; t[i]=c; } } main( ) { char s[81]; printf("Please enter a character string:/n"); gets(s); printf("/n/nBefore sorting:/n%s",s); ______;/*第三空*/ printf("/nAfter sorting decreasingly:/n%s/n",s); }
[填空题]下列给定程序中,函数fun( )的功能是;利用插入排序法对字符串中的字符按从小到大的顺序进行排序。插入法的基本方法是:先对字符串中的头两个元素进行排序,然后把第3个字符插入到前两个字符中,插入后前3个字符依然有序;再把第4个字符插入到前3个字符中,待排序的字符串已在主函数中赋予。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <String.h>
#include <stdio.h>
#define N 80
void insert(char *aa)
iht i, j, n; char ch;
n=strlen (aa);
for (i=1; i<n; i++)
/**********************************/
c=aa[i];
j=i-1;
while ((j>=0) && (ch<aa [j] ))
aa [j+l]=aa[j];
j--;

aa [j+l]=ch;


main ( )
char a [N] = "QWERTYUIOPASDFGHJKIMNBVCXZ";
int i;
printf("The original string: %s/n",a);
insert (a);
printf("The string after sorting:
%s/n/n", a);

[填空题]下列给定程序中,函数fun( )的功能是:利用插入排序法对字符串中的字符按从大到小的顺序进行排序。插入法的基本方法是:先对字符串中的头两个元素进行排序,然后把第3个字符插入到前两个字符中,插入后前3个字符依然有序;再把第4个字符插入到前3个字符中,待排序的字符串已在主函数中赋予。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <string.h> #include <stdio.h> #define N 80 void insert(char *aa) { int i,j,n; char ch; n=strlen(aa); for(i=1;i<n;i++) { ch=aa[i]; j=i-1; /*************found*************/ while((j>=0)||(ch>aa[j])) { aa[j+1]=aa[j]; j--; } /*************found*************/ aa[j]=ch; } } main( ) { char a[N]="JRTYDFKLIOPQWEGHMNBVCUASXZ"; int i; printf("The original string:%s/n",a); insert(a); printf("The string after sorting:%s/n/n",a); }
[简答题]函数fun( )的功能是:将字符串中的字符按逆序输出,但不改变字符串中的内容。例如,若字符串为abcd,则应输出dcba。
#include<stdio.h>
/**********found**********/
fun(char a)
if(*a)
fun(a+1);
/**********found**********/
printf("%c"*a);


main( )
char s[10]="abcd";
printf("处理前字符串=%s/n处理后字符串=",s);
fun(s);printf("/n");

[简答题]填空题 请补充函数fun( ),该函数的功能是:把字符串str中的字符按字符的ASCII码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。 例如,如果输入“cdefgh”,则输出为“hgfedc”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include #define N 80 void fun(char s[],int n) { int i, j; char ch; for(i=0;i
[简答题]函数fun的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码升序排序后输出。
例如,若输入:edcba,则应输出:abcde。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include<stdio.h>
void fun(char t[])

Char c;
int i,j;
/**********found***********/
for(i=strlen(t);i;i--)
for(j=0;j<i;j++)
/**********found***********/
if(t[j]<t[j+1])

c=[j];
t[j]=t[j+1];
t[j+1]=c;


main( )

char s[81];
printf("/nPlease enter a character string:");
gets(s);
printf("/n/nBefore sorting:n/"%s/"",s);
fun(s);
printf("/nAfter sorting decendingly:/n/"%s/"",s);

我来回答:

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

订单号:

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