更多"下列给定程序中,函数fun的功能是:将p所指字符串中的所有字符复制到b"的相关试题:
[简答题]下列给定程序中,函数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的功能是:将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个字符之后插入一个空格。例如,在调用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 ");
}
[多项选择]填空题
请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf("Enter the position of the string
deleted:");
scanf(【1】);
for(i=0;i
[填空题]请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 80
main( )
char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf "Enter the position of the string deleted:");
scanf( 【1】 );
for(i=0;i<n;i++)
【2】
str2[i]=‘/0’;
printf("The new string is:%s/n", 【3】 );
[填空题]在给定程序中,函数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);
[简答题]给定程序MODI1.C中函数fun的功能是: 比较两个字符串,将长的那个字符串的首地址作为函数值返回。
请改正函数fun中指定部位的错误, 使它能得出正确的结果。
注意: 不要改动main函数, 不得增行或删行, 也不得更改程序的结构!
给定源程序:
#include
char fun(char *s, char *t)
{ int sl=0,tl=0; char *ss, *tt;
ss=s; tt=t;
while(*ss)
{ sl++;
(*ss)++;
}
while(*tt)
{ tl++;
(*tt)++;
}
if(tl>sl) return t;
else return s;
}
main( )
{ char a[80],b[80],*p,*q; int i;
printf("/nEnter a string : "); gets(a);
printf("/nEnter a string again : "); gets(b);
printf("/nThe longer is :/n/n/"%s/"/n",fun(a,b));
}
[填空题]下列给定程序中,函数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);
[填空题]给定程序MODI1.C函数fun的功能是:依次取出字符串中所有数字字符,形成新的字符串,并取代原字符串。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
void fun(char *s)
int i,j;
for(i=0,j=0; s[i]!=’/0’;i++)
if(s[i]>=’0’&& s[i]<=’9’)
/**********found**********/
s[j]=s[i];
/**********found**********/
S[j]="/0";
void main( )
char item[80];
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( )的功能是:读人一个字符串(长度<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的功能是:首先把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);
[简答题]给定程序MODI1.C中函数fun的功能是: 依次取出字符串中所有数字字符, 形成新的字符串, 并取代原字符串。
请改正函数fun中指定部位的错误, 使它能得出正确的结果。
注意: 不要改动main函数, 不得增行或删行, 也不得更改程序的结构!
给定源程序:
#include
void fun(char *s)
{ int i,j;
for(i=0,j=0; s[i]!=’/0’; i++)
if(s[i]>=’0’ && s[i]<=’9’)
s[j]=s[i];
s[j]="/0";
}
main( )
{ char item[80];
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 );
}