更多"下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形"的相关试题:
[填空题]下列给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形参t所指字符串相同的串,找到后返回该串在字符串数组中的位置(即下标值),若未找到则返回-1。ss所指字符串数组中共有N个内容不同的字符串,且串长小于M。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include <stdio.h>
#include <string.h>
#define N 5
#define M 8
int fun(char (*ss)[M], char *t)
int i;
/******************found*******************/
for(i=0; i<______; i++)
/******************found*******************/
if(strcmp(ss[i], t)==0)
return______;
return(-1);
main( )
char ch[N][M]("if", "while", "switch", "int", "for", t[M];
int n, i;
printf("/nThe original string/n/n");
for(i=0; i<N; i++)puts(ch[i]);
printf("/n");
printf("/nEnter a string for search:");
gets(t);
n=fun(ch, t);
/******************found*******************/
if(n==______)
printf("/nDon’t found!/n");
else
printf("/nThe position is %d./n", n);
[填空题]在给定程序中,函数fun的功能是:在形参ss所指字符串数组中查找与形参t所指字符串相同的串,找到后返回该串在字符串数组中的位置(下标值),未找到则返回-1,ss所指字符串数组中共有N个内容不同的字符串,且串长小于N。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
#include<string.h>
#define N 5
#define M 8
int fun(char(*ss)[M],char *t)
int i:
/**********found**********/
for(i=0;i< (1) ;i++)
/**********found**********/
if(stremp(ss[i],t)==0)return (2) ;
return -1;
void main( )
char ch[N][M]="f","while","switch","int","for",t[M];
int n,i;
printf("/nThe original stringin/n");
for(i=0;i<N;i++)puts(ch[i]);
printf("/n");
printf("/nEnter a string for search: ");
gets(t);
n=fun(eh,t);
/**********found**********/
if(n== (3) )printf("/nDon’t found!/n");
else printf("/nThe position is%d./n",n);
[填空题]给定程序中,函数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的功能是将形参给定的字符串、整数、浮点数写到文本 文件中,再用字符方式从此文本文件中逐个读入并显示在终端屏幕上。 请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
void fun(char *s, int a, double f)
{
__1__ fp;
char ch;
fp = fopen("file1.txt", "w");
fprintf(fp, "%s %d %f/n", s, a, f);
fclose(fp);
fp = fopen("file1.txt", "r");
printf("/nThe result :/n/n");
ch = fgetc(fp);
while (!feof(__2__)) {
putchar(__3__); ch = fgetc(fp); }
putchar(’/n’);
fclose(fp);
}
main( )
{ char a[10]="Hello!"; int b=12345;
double c= 98.76;
fun(a,b,c);
}