更多"下列给定程序中,函数fun的功能是:将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所指字符串中的所有数字字符移到所有非数字字符之后,并保持数字字符串和非数字字符串原有的先后次序。例如,形参s所指的字符串为def35adh3kjsdf7,执行结果为defadhkjsdf3537。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
#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’0&&s[i]<=’9’)
/**********found**********/
t2[j]=s[i]; (1) ;
else t1[k++]=s[i];
t2[j]=0;t1[k]=0;
/**********found**********/
for(i=0;i<k;i++) (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 result is:%s/n",s);
[填空题]给定程序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( );/*本函数与考生答题无关,考生不得改动,否则后果自负。*/
}
[填空题]给定程序中,函数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
[填空题]下列给定程序中,函数fun( )的功能是;将s所指字符串中的字母转换为按字母序列的后续字母(但Z转化为A,z转化为 a),其他字符不变。
请改正函数fun( )中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
void fun(char *s)
/*************found**************/
{ while(*s!=’@’)
{ if(*s>=’A’ &*s<=’z’||*s>=’a’&&*s<=’z’)
{if(*s==’Z’) *S=’A’;
else if(*S==’z’) *s=’a’;
else *s+=1;
}
/*************found**************/
(*s)++;
}
}
main( )
{ char s[80];
clrscr( );
printf("/n Enter a string with length <80:/n/n");gets(s);
printf("/n The string:/n/n");puts(s);
fun(s);
printf("/n/n The Cords:/n/n");puts(s);
}