更多"下列给定程序中,函数fun的功能是:求ss所指字符串数组中长度最短的字"的相关试题:
[简答题]下列给定程序中,函数fun的功能是:求ss所指字符串数组中长度最短的字符串所在的行下标,作为函数值返回,并把其串长放在形参n所指的变量中。ss所指字符串数组中共有M个字符串,且串长小于N。
请在下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include < string.h >
#define M 5
#define N 20
int fun(char (* ss)[N], int * n)
int i, k=0, len=N;
/********** found********** /
for(i=0; i< (1) ; i++)
len=strlen (ss[ i]);
if(i==0) * n=fen;
/********** found*********** /
iffen (2) * n)
* n=len;
k=i;
/********** found********** /
return ( (3) );
main ( )
char ss[M] [N]="shanghai",
"guangzhou", "beijing", "tianjing",
"chongqing" ;
int n, k, i;
printf (" /nThe original strings
are :/n");
for (i=0; i<M; i++)puts (ss[i]);
k=fun (ss, &n);
printf ("/nThe length of shortest
string is : % d/n", n);
printf ("/nThe shortest st
[填空题]给定程序中,函数fun( )的功能是求ss所指字符数组中长度最短的字符串所在的行下标,作为函数值返回,并把其串长放在形参n所指变量中。ss所指字符数组中共有M个字符串,且串长<N。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
#include<stdio.h>
#include<string.h>
#define M 5
#define N 20
int fun(char(*ss)[N],int *n)
int i,k=0,len=N;
/**********found**********/
for(i=0;i< (1) ;i++)
len=strlen(ss[i]);
if(i==0)*n=len;
/**********found**********/
if(len (2) *n)
*n=len;
k=i;
/**********found**********/
return (3) ;
main( )
char ss[M][N]="shanghai",
"guangzhou","beijing","tianjing","chongqing";
int n,k,i;
printf("/nThe original strings are:/n");
for(i=0;i<M;i++)puts(ss[i]);
k=fun(ss,&n);
printf("/nThe length of shortest string is:%d/n",n);
printf("/nThe shortest string is:%s/n",ss[k]);
[简答题]编写函数fun,其功能是:求ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串“123412132”,输入字符为“1”,则输出3。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<sfdlib.h>
#include<conio.h>
#include<sfdio.h>
#define M 81
int fun(char*SS,char C)
void main( )
char a[M],ch;
system("CLS");
printfl(/nPlease enter a string:");
getsia);
printf("/nPlease enter a char:");
ch=getchar( );
printf("/nThe number of the char is:%d/n",fun(a,ch));
[填空题]在给定程序中,函数fun的功能是:将a和b所指的两个字符串转换成面值相同的整数,并进行相加作为函数值返回,规定字符串中只含9个以下的数字字符。
例如:主函数中输入字符串:32486和12345,在主函数中输出的函数值为:44831。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define N 9
long ctod(char *s)
long d=0;
while(*s)
if(isdigit(*s))
/**********found**********/
d=d*10+*s- (1) ;
/**********found**********/
(2) ;
return d;
long fun(char *a,char *b)
/**********found**********/
return (3) ;
void main( )
char s1[N],s2[N];
do
printf("Input string s1: ");
gets(s1);
while(strlen(s1)>N);
do
printf("Input string s2: ");
gets(s2);
while(strlen(s2)>N);
printf("The result is: %1d/n",fun(s1,s2));
[填空题]给定程序中,函数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( )的功能是:依次取出字符串中所有的字母,形成新的字符串,并取代原字符串。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动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);
}