更多"下列程序中函数reverse( )的功能是将a所指数组中的内容进行逆置"的相关试题:
[多项选择]下列给定程序中,函数fun的功能是:将s所指字符串的正序和反序进行连接,形成的新串放在t所指的数组中。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动mam函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#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的功能是:在形参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的功能是:将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。
请在程序的下画线处填入正确的内容,并把下画线删除,使程序得出正确的结果。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
[试题源程序]
#include<stdio.h>
typedef struct
char name[10];
int age;
)STD;
STD fun(STD std[], int n)
STD max; int i;
/**********found**********/
max= (1) ;
for(i=1; i<n; i++)
/**********found**********/
if(max.age< (2) )
max=std[i];
return max;
main( )
STD std[5]="aaa", 17, "bbb", 16, "ccc", 18, "ddd", 17, "eee", 15;
STD max;
max=fun(std, 5);
printf("/nThe result: /n");
/**********found**********/
printf("/nName: %s, Age: %d/n", (3) , max.age);
[填空题]在给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。
文件BLANK1.C内容如下:
#include<stdio.h>
typedef struct
char name[10];
int age;
STD;
STD fun(STD std[],int n)
STD max;
int i;
/**********found**********/
max= (1) ;
for(i=1;i<n;i++)
/**********found**********/
if(max.age< (2) )max=std[i];
return max;
void main( )
STD std[5]="aaa",17,"bbb",16,"ccc",18,"ddd",17,"eee",15;
STD max;
max=fun(std,5);
printf("The result/n");
/***********found**********/
printf("Name:%s,Age:%d/n", (3) ,max.age);
[填空题]下列程序中函数fun的功能是统计person所指结构体数组中所有性别(sex)为M的记录个数,存入变量n中,并作为函数值返回,请填空。
#include<stdio.h>
#define N 3
typedef struct
int num;char nam[10];char sex;) ss;
int fun(SS person[])
for(i=0;i<N;i++)
int i,n=0;
if(______==’M’)n++;
return n;
void main( )
SS W[N]=1,"AA",’F’),2,"BB",’M’),3,"CC",’M’;int n;
n=fun(w);printf("n=%d/n",n);
[简答题]下列给定程序中,函数fun的功能是:求ss所指字符串数组中长度最短的字符串所在的行下标,作为函数值返回,并把其串长放在形参n所指的变量中。ss所指字符串数组中共有M个字符串,且串长小于N。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<scdio.h>
#include<string.h>
#define M 5
#define N 20
int funIchar(*ss)[N].int*n)
int i.k=0,len=N;
/********found********/
for(i=0;i小于 (1) ;i++]
len=strlen(ss[i]);
if(i==O)*n=len;
/********found********/
if(len (2) *n)
*n=len;
k=i;
/********fOund********/
return( (3) );
main( )
char ss[M][N]=["shanghai","guangzhou","beijing","tianjin","chongqing");
int n,k,i;
printff"/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]);
[填空题]函数rotate的功能是:将a所指N行N列的二维数组中的最后一行放到b所指二维数组的第0列中,把a所指二维数组中的第0行放到b所指二维数组的最后一列中,b所指二维数组中其他数据不变。
#define N 4
void rotate(int a[][N],int b[][N])
int i,j;
for(i=0;i<N;i++)
(b[i][N-1]= ; =a[N-1][i];