更多"下列给定程序中,函数fun( )的功能是:依次取出字符串中所有的数字字"的相关试题:
[填空题]给定程序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( )的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。
请改正函数fun( )中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.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";
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);
[填空题]下列给定程序中,函数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);
}
[填空题]请补充函数fun( ),该函数的功能是:依次取出字符串中所有的小写字母以形成新的字符串,并取代原字符串。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
void fun(char *s)
{
int i=0;
char *p=s;
while( 【1】 )
{
if (*p>=’a’&&*p<=’z’)
{
s[i]=*p;
【2】 ;
}
p++;
}
s[i]= 【3】 ;
}
main( )
{
char str[80];
clrscr( );
printf("/nEnter a string:");
gets(str);
printf("/n/nThe string is:/%s/n",str);
fun(str);
printf("/n/nThe string of changing
is:/%s/n",str);
}
[简答题]改错题
下列给定程序中,函数fun( )的功能是:依次取出字符串中所有的字母,形成新的字符串,并取代原字符串。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
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);
}
[简答题]下列给定程序中,函数fun( )的功能是:在字符串的最前端加入n个*号,形成新串,并且覆盖原串。
注意:字符串的长度最长允许79。
请改正函数fun( )中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序;
#include <stdio.h>
#include <strzng.h>
#include <conio.h>
/*****************found***************/
void fun(char s[], int n)
{
char a[80],*p;
int i;
/*****************found***************/
s=p;
for(i=0; i<n; i++) a[i]=’*’;
do
{a[i]=*p;
/*****************found***************/
i++;
}while(*p);
a[i]=0;
strcpy(s,a);
}
main( )
{ int n;char s[80];
clrscr( );
printf("/nEnter a string:");gets(s);
printf("/nThe string/%s/n",s);
printf("/nEnter n(number of*):");scanf
("%d",&n);
fun(s,n);
printf("/nThe string after inster:
/%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