更多"下列给定程序中,函数fun( )的功能是:将m(1≤m≤10)个字符串"的相关试题:
[填空题]下列给定程序中,函数fun( )的功能是:将m(1≤m≤10)个字符串连接起来,组成一个新串,放入pt所指字符串中,例如:把3个串abc,CD,EF串联起来,结果是abcCDEF。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <string.h>
#include <stdio.h>
/*************found**************/
int fun(char str[] [10],int m, char *pt)
int k,q,i,j=0;
for(k=0;k<m;k++)
q=strlen(str[k]);
j+=q;
for(i=0;i<q;i++)
/*************found**************/
pt[i]=str[k,i];
pt+=q;
pt[0] =0;
pt-=j;
main ( )
int m, h;
char s[10] [10],p[120];
clrscr ( );
printf("/nPlease enter m: ");
scanf("%d",&m); gets(s[0]);
printf ("/nPlease enter %d string:In ",m);
for(h=0;h<m;h++) gets(s[h]);
fun (s,m,p);
printf("/nThe result is :%s/n ",p);
[填空题]下列给定程序中,函数fun( )的功能是:将m(1≤m≤10)个字符串反着连接起来,组成一个新串,放入pt所指字符串中,例如:把3个串DEG,ac,df反着串联起来,结果是dfacDEG。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main( )函数,不得增行或者删行,也不得改变程序的结构!
试题程序:
#include <conio.h>
#include <string.h>
#include <stdio.h>
void fun(char str[][10],int m,char *pt)
int k,q,i,j=0;
/*************found*************/
for(k=m;k>0;k--)
q=strlen(str[k]);
j+=q;
for(i=0;i<q;i++)
pt[i]=str[k][i];
pt+=q;
pt[0]=0;
/*************found**************/
pt=j;
main( )
int m,h;
char s[10][10],p[120];
clrscr( );
printf("/nPlease enter m:");
scanf("%d",& m);
printf("/nPlease enter%d string:/n",m);
gets(s[0]);
for(h=0;h<m;h++)
gets(s[h]);
fun(s,m,p);
printf("/nThe result is:%s/n",p);
[填空题]下列给定程序中函数fun的功能是:将p所指字符串中的所有字符复制到b中,要求每复制三个字符之后插入一个空格。
例如,若给a输入字符串:”ABCDEFGHIJK”,调用函数后,字符数组b中的内容为:”ABC DEF GHI JK”。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(char*p,char*b)
int i,k=0;
while(*p)
i=1;
while(i<=3&&*p)
/*********found*********/
b[k]=p;
k++;p++;i++;
if(*p)
/*********found*********/
b[k++]="";
b[k]=’/0’;
void 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( )的功能是:将字符串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( )的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。
例如:输入dafhc,则应输出hfdca。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
/**********************found***********************/
int fun(char t[ ])
{
char c;
int i,j;
for(i=0;i
[填空题]下列给定程序中,函数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的功能是:将P所指字符串中的所有字符复制到b中,要求每复制3个字符之后插入一个空格。
例如,若给a输入字符串:“ABCDEFGHIJK”,调用函数后,字符数组b中的内容为:“ABC DEFGHI JK”。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(char*p,char*b)
(int i,k=0;
while(*p)
i=1;
while(i<=3&&*p)
/********found********/
b[k]=p;
k++;p++;1++;
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");
[简答题]下列给定程序中,函数fun的功能是:将p所指字符串中的所有字符复制到b中,要求每复制3个字符之后插入一个空格。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h >
void fun (char * p, char * b)
int i, k=0;
while (* p)
i=1;
while (i<=3 && * p)
/**********found********** /
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( )的功能是逐个比较a,b两个字符串对应位置中的字符,把ASCII值小或相等的字符依次存放到c数组中,形成一个新的字符串。
例如:a中的字符串为fshADfg,b中的字符串为sdAEdi,则c中的字符串应为fdAADf。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
void fun(char *p,char *q,char *c)
{ int k=0;
while(*p||*q)
/**********************found***********************/
{ if (*p<=*q)
c[k]=*q;
else c[k]=*p;
if(*p) p++;
if(*q) q++ ;
/**********************found***********************/
k++
}
}
main( )
{ char a[10]="fshADfg",b[10]="sdAEdi",c[80]={’’/0’’};
fun(a,b,c);
printf("The string a:"); puts(a);
printf("The string b:"); puts(b);
printf("The result :"); puts(c);
}
[填空题]下列给定程序中,函数fun( )的功能是逐个比较a,b两个字符串对应位置中的字符,把ASCII值小或相等的字符依次存放到c数组中,形成一个新的字符串。
例如:a中的字符串为fshADfg,b中的字符串为sdAEdi,则c中的字符串应为fdAADf。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <strinq.h>
void fun(char *p,char *q,char *c)
int k=0;
while(*p || *q)
/**********found**************/
if (*p<=*q)
c[k]=*q;
else c[k]:*p;
if(*p) p++;
if(*q) q++;
/**+**********found**************/
k++
main( )
char a[10]="fshADfg",b[10]="sdAEdi",
c[80]=’/0’);
fun(a,b,c);
printf("The string a:");puts
- (a);
printf("The string b:");puts - (b);
printf("The result:");puts - (c);
[简答题]下列给定程序中,函数fun的功能是:用冒泡法对6个字符串进行升序排列。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdlib.h >
#include <string.h>
#include <conio.h>
#include <stdio.h>
#define MAXLINE 20
fun (char * pstr[6])
int i, j;
char * p;
for(i=0; i<5; i++)
/********** found********** /
for(j=i+1, j<6, j++)
if (strcmp (* (pstr+i), (pstr+
j))>0)
p=* (pstr+i);
/********** found********** /
* (pstr+i)=pstr+j;
* (pstr+j)=p;
void main ( )
int i;
char * pstr[6], str[6] [MAXLINE];
system ("CLS");
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 sor-
ting:/n ");
for (i=0; i<6; i++)
printf ("% s/n ", pstr[i])
[简答题]下列给定程序中,函数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]);