更多"给定程序中,函数fun( )的功能是将s所指字符串中的所有数字字符移到"的相关试题:
[填空题]下列给定的程序中,函数fun( )的功能是;将s所指字符串中出现的n所指字符串全部替换成t2所指字符串,所形成的新的字符串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。例如:当s所指字符串中所指的内容为 abcdabfab,t1所指字符串中的内容为ab,t2所指字符串中的内容为99时,结果在w所指的数组中的内容应为99cd99f99。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
int fun (char *s, char *t1, char *t2, char *w)
int i; char *p,*r,*a;
strcpy(w,s);
while (*w)
p=w; r=t1;
/*************found**************/
while (r)
if (*r= =*p) r++;p++;
else break;
if (*r= =’/0’)
a=w; r=t2;
/*************found**************/
while (*r)*a=*r;a++;r++
w+=strlen(t2);
else w++;
main( )
char s[100],t1[100],t2[100],w[100];
clrscr( );
printf("/nPlease enter string S: ");
scanf("%s",s);
[简答题]给定程序MODI1.C中函数 fun 的功能是:将s所指字符串中最后一次出现的与t1所指字符串相同的子串替换成t2所指字符串,所形成的新串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。
例如,当s所指字符串中的内容为:"abcdabfabc",t1所指子串中的内容为:
"ab",t2所指子串中的内容为:"99"时, 结果,在w所指的数组中的内容应为:
"abcdabf99c"。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
int fun (char *s, char *t1, char *t2 , char *w)
{
int i; char *p , *r, *a;
strcpy( w, s );
/************found************/
while ( w )
{ p = w; r = t1;
while ( *r )
/************found************/
IF ( *r == *p )
{ r++; p++; }
else break;
if ( *r == ’/0’ ) a = w;
w++;
}
r = t2;
while ( *r ){ *a = *r; a++; r++; }
}
main( )
{
char s[100], t1[100], t2[100], w[100];
printf("/nPlease enter string S:"); scanf("%s", s);
printf("/nPlease enter substring t1:"); scanf("%s", t1);
printf("/nPlease enter substring t2:"); scanf("%s", t2);
if ( strlen(t1)==strlen(t2) )
{ fun( s, t1, t2, w);
printf("/nThe result is : %s/n", w);
}
else printf("/nError : strlen(t1) != strlen(t2)/n");
}
[简答题]下列给定程序中函数fun的功能是:将s所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的次序。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
void fun (char * s)
int i, j=0, k=0;
char t1[80], t2[80];
for(i=0; s[i]!=’/0’; i++)
if(s[i]>=’0’ &&s[i]<=’9’)
t2[j]=s[i];
(1) ;
else
t1[k++]=s[i];
t2[j]=0;
t1[k]=0;
for (i=0; i<k; i++)
(2) ;
for (i=0; i< (3) ; i++)
s[k+i]=t2[i];
main ( )
char s [ 80 ]="ba3a54j7sd567sdffs";
printf ("/nThe original string is:
% s/n", s);
fun (s);
printf ("/nThe result is :% s/n", s);
[填空题]下列给定程序中,函数fun的功能是:将s所指字符串的正序和反序进行连接,形成的新串放在t所指的数组中。
例如,当s所指字符串为“ABCD”时,t所指字符串中的内容应为“ABCDDCBA”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
/*************found****************/
void fun(char s,char t)
int i,d;
d=strlen(s);
for(i=0;i<d;i++)
t[i]=s[i];
for(i=0;i<d;i++)
t[d+i]=s[d-1-i];
/************found**************/
t[2*d-1]=’/0’;
main( )
char s[100],t[100];
printf("/nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("/nThe result is:%s/n",t);
[简答题]下列给定程序中,函数fun的功能是:将s所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的次序。
例如,s所指的字符串为“def35adh3kjsdf7”,执行后结果为“defadhkjsdf3537”。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stldio.h>
void fun(char*s)
(
inf j,j=O,k=O;
char tl[80],t2[80];
for(i=0;s[i]!=’/0’;i++)
if(s[i]>=’O’&&s[i]<=’9’)
t2[j]=s[i];
/********found********/
(1) ;
else
tl[k++]=s[i];
t2[j]=O;
t1[k]=O;
for(i=O;i<k;i++)
/********found********/
(2) ;
/********found********/
for(i=0;i< (3) ;i++)
s[k+i]=t2[i];
main( )
char s[80)="ba3a54j7sd567sdffs";
printf("/nThe original string is%s/n,s);
fun(s);
printf("/nThe restult is%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);
[填空题]下列给定程序中函数fun的功能是:统计substr所指的字符串在str所指的字符串中出现的次数。
例如,若字符串为aaas 1kaaas,子字符串为as,则应输出2。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(char*str,char*substr)
int i,j,k,num=0;
/*********found*********/
for(i=0,str[i],i++)
for(j=i,k=0;
substr[k]==str[j];
k++,j++)
/*********found*********/
If(substr[k+1]==’/0’)
num ++;
break;
return num;
main( )
char str[80],substr[80];
printf("Input a string:");
gets(str);
printf("Input a substring:");
gets(substr);
printf("%d/n".fun(str,substr));
[填空题]给定程序MODI1.C中函数fun的功能是:将s所指字符串的正序和反序进行连接,形成一个新串放在t所指的数组中。
例如,当s所指字符串为"ABCD"时,则t所指字符串中的内容应为:ABCDDCBA。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<string.h>
/**********found**********/
void fun(char s,char t)
int i,d;
d=strlen(s);
for(i=0;i<d;i++)t[i]=s[i];
for(i=0;i<d;i++)t[d+i]=s[d-1-i];
/**********found**********/
t[2*d-1]=’/0’;
void main( )
char s[100],t[100];
printf("/nPlease enter string S: ");
scanf("%s",s);
fun(s,t);
printf("/nThe result is: %s/n",t);
[填空题]下列给定程序中,函数fun( )的功能是:从s所指字符串中,找出t所指字符串的个数作为函数值返回。例如,当s所指字符串中的内容为abcdabfab,t所指字符串的内容为ab,则函数返回整数3。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
int fun (char *s, char *t)
{int n; char *p, *r;
n=0;
while(*s)
{p=s;
r=t;
while (*r)
/**************found**************/
if(*r==*p) {r++; p++}
else break;
/*************found**************/
if(r==’/0’)
n++;
s++;
}
return n;
}
main( )
{char s[100], t[100]; int m;
clrscr( );
printf("/nPlease enter string s: ");
scanf ("%s",s);
printf("/nPlease enter substring t: ");
scanf ("%s",t);
m=fun (s,t);
printf("/nThe result is: m=%d/n", m);
}
[填空题]给定程序MODI1.C中函数fun的功能是:将s所指字符串中位于奇数位置的字符或ASCII码为偶数的字符放入t所指数组中(规定第一个字符放在第0位中)。
例如,字符串s中的数据为:AABBCCDDEEFF,则字符串t中的数据为:ABBCDDEFF。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
文件MODI1.C内容如下:
#include<stdio.h>
#include<string.h>
#define N 80
void fun(char *s,char t[])
int i,j=0,n;
n=strlen(s);
for(i=0;i<n;i++)
/**********found**********/
if(i%2&&s[i]%2==0)t[j++]=s[i];
/**********found**********/
t[i]=’/0’;
void main( )
char s[N],t[N];
printf("/nPlease enter string s:");
gets(s);
fun(s,t);
printf("/nThe result is: %s/n",t);
[填空题]下列给定程序中,函数fun( )的功能是:计算s所指字符串中含有t所指字符串的数目,并作为函数值返回。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <string.h>
#include <stdio.h>
#define N 80
int fun(char *s,char *t)
int n;
char *p, *r;
n=0;
while(*s)
p=s;
/**************found***************/
r=p;
while(*r)
if*r==*p) r++; p++;
else break;
/**************found***************/
if(*r==0)
n++;
s++;
return n;
main( )
char a[N],b[N]; int m;
clrscr( );
printf("/nPlease enter string a:");
gets(a);
printf("/nPlease enter substring b:");
gets(b);
m=funa,b);
printf("/nThe result is :m=%d/n",m);
[填空题]给定的程序中,fun函数的功能是:将s所指字符串中除了下标为偶数,同时ASCH值为偶数的字符除外,其余的全部删除;串中剩余字符所形成的一个新串放在t所指的数组中。如:若s所指字符串中的内容为:”desktop12345",t所指字符串中的内容为:"dtp24"。
请在程序的下划线处填写正确的内容,使程序得到正确的结果。
#inClUde <conio.h>
#include <stdio.h>
#include <string.h>
void fun (Char *s,char t[])
{
int i,j;
for(i=0,j=0; (1) ;i++)
if(i%2==0&&s[i]%2==0) (2) ;
(3) ;
}
main( )
{ char s[100],t[100];
clrscr( );
printf("/nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("/n The result is:% s/n",t);
NONO( );/*本函数与考生答题无关,考生不得改动,否则后果自负。*/
}