更多"给定程序中函数fun的功能是:首先把b所指字符串中的字符按逆序存放,然"的相关试题:
[填空题]下列给定程序中,函数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),将该字符串中的所有字符按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的功能是:将a和b所指的两个字符串转换成面值相同的整数,并进行相加作为函数值返回,规定字符串中只含9个以下的数字字符。
例如:主函数中输入字符串:32486和12345,在主函数中输出的函数值为:44831。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define N 9
long ctod(char *s)
long d=0;
while(*s)
if(isdigit(*s))
/**********found**********/
d=d*10+*s- (1) ;
/**********found**********/
(2) ;
return d;
long fun(char *a,char *b)
/**********found**********/
return (3) ;
void main( )
char s1[N],s2[N];
do
printf("Input string s1: ");
gets(s1);
while(strlen(s1)>N);
do
printf("Input string s2: ");
gets(s2);
while(strlen(s2)>N);
printf("The result is: %1d/n",fun(s1,s2));
[填空题]下列给定程序中,函数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的功能是:求出形参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