填空题fun函数的功能是:首先对a所指的N行N列的矩阵,找出各行中的最大数,再求这 N个最大值中的最小的那个数作为函数值返回。请填空______。 #include <stdio.h> #define N 100 int fun(int(*a)[N]) int row, col,max,min; for(row=0;row<N;row++) for(max=a[row][0],col=1; col<N;col++) if( ) max=a[row][col]; if(row==0) min=max; else if( ) min=max; return min;
填空题给定程序中,函数fun的功能是:找出形参s所指字符串中出现频率最高的字母(不区分大小写),并统计出其出现的次数。
例如,形参s所指的字符串为:abcAbsmaxless,程序执行后的输出结果为:
letter "a" : 3 times
letter "s" : 3 times
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void fun(char *s)
{int k[26]={0},n,i,max=0;char ch;
while(*s)
{if(isalpha(*s)){
/**********found**********/
ch=tolower(______);
n=ch-"a";
/**********found**********/
k[n]+=______;
}
s++;
/**********found**********/
if(max<k[n])max=______;
}
printf("/nAfter count:/n");
for(i=0;i<26;i++)
if(k[i]==max)printf("/nletter "%c":%dtimes/n",i+"a",k[i]);
}
main()
{char s[81];
printf("/nEnter a string:/n/n");gets(s);
fun(s);
}
填空题以下fun函数的功能是在N行M列的整型二维数组中,选出一个最大值作为函数值返回,请填空。(设M,N已定义) int fun(int a[N][M]) int i,j,row=0,co1=0; for(i=0;i<N;i++) for(i=0;j<M;j++) if(a[i][j]>a[row][co1])row=i;co1=j; return______;
填空题以下程序运行后的输出结果是 【11】 。
main ( )
{ char a[]="Language",b[]="Programe";
char *p1,*p2; int k;
p1=a; p2=b;
for(k=0;k<=7;k++)
if(*p1+k)==*(p2+k)} printf("%c",*(p1+k));
}
填空题下面程序
main()
{ int i,j,m,n;
i=5;
j=10;
m=++i;
n=j++;
printf("%d,%d,%d,%d",i,j,m,n);
}
运行后,i,j,m,n的值分别是_______。
填空题函数fun的功能是:从三个形参a,b,c中找出中间的那个数,作为函数值返回。
例如,当a=3,b=5,c=4时,中间的数为4。 注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
试题程序: #include<stdio.h> int fun(int a,int
b,int c) { int t;
t=(a>b)?(b>c?b:(a>c?c:{{U}} {{U}} 1 {{/U}} {{/U}})):
((a>c)?{{U}} {{U}} 2 {{/U}} {{/U}}:((b>c)?c:{{U}}
{{U}} 3 {{/U}} {{/U}})); return t;
} void main() { int
a1=3,a2=5,a3=4,r; r=fun(a1,a2,a3);
printf("/nThe middle number is:%d/n",r); }
填空题若有定义int a=10,b=9,c=8;,接着顺序执行下列语句,变量b中的值是{{U}} 【6】 {{/U}}。
c=(a-=(b-5));
c=(a%11)+(b=3);
填空题单元测试又称模块测试,=般采用______测试。
填空题以下程序的输出结果是{{U}} 【12】 {{/U}}。
void fun()
{ static int a=0;
a+=2; printf("%d",A) ;
}
main()
{ int cc;
for(cc=1;CC<4;CC++)fun();
printf("/n");
}
填空题以下程序的功能是将文件stud_data中第i个学生的姓名、学号、年龄、性别输出,请把程序补充完整。
#include<stdio.h>
struct student_type
{
char name[10];
int num;
int age;
char sex;
}stud[10];
int main()
{
int i;
FILE ______;
if((fp1=fopen("stud_data", "rb"))==NULL)
{
printf("error!/n");
exit(0);
}
scanf("%d",
fseek(______);
fread([______, sizeof(struct student_type), 1, fp1);
printf("%s%d%d%c/n", stud[i].name, stud[i].num, stud[i].age, stud[i].sex);
fclose(fp1);
return 0;
}
填空题下面程序的功能是:计算1~10之间的奇数之和与偶数之和,请填空。
#include<stdio.h>
main()
{ int a,b,c,i;
a=C=0;
for(i=0;i<=10;i+=2)
{a+=i;
______;
c+=b;}
printf("偶数之和=%d/n",a);
printf("奇数之和=%d/n",c-11);}
填空题若有以下定义和语句,sizeof(a)的值是{{U}} 【14】 {{/U}},sizeof(a.share)的值是{{U}} 【15】 {{/U}}。
struct date
{ int day;
int month;
int year;
union
{ int share1;
float share2;
}share;
}a;
填空题以下程序的功能是:将输入的正整数按逆序输出。例如:若输入135则输出531。请填空。
#include <stdio.h>
main()
{ int n, s;
printf("Enter a number:"); scanf("%d",
printf("Output: ");
do
{ s=n%10; printf("%d",s); {{U}}[10] {{/U}}; }
while (n!=0);
printf("/n');
}
填空题下列给定程序中,函数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的功能是计算Xn
double fun(double x,int n)
{ int i; double y=1;
for(i=1;i<=n;i++) y=y*x;
return y;}
主函数中已经正确定义m,a,b变量并赋值,并调用fun函数计算:m=a4+b4-(a+b)3。实现这一计算的函数调用语句为【 】。
填空题函数fun的功能是:从三个形参a、b、c中找出中间的数,并作为函数值返回。
例如,当a=3,b=5,c=4时,中间的数为4。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数fun的下划线上填入所编写的若干表达式或语句,并把下划线删除。
试题程序:
#include<stdio.h>
int fun(int a,int b,int c)
{
int t;
/**********found**********/
t=(a>b)?(b>?b:(a>c?c:______)):((a>c)?______:((b>c)?c:______));
return t;
}
main()
{
int a1=3,a2=5,a3=4,r;
r=fun(a1,a2,a3);
printf("/nThe middle number is:%d/n",r);
}
填空题以下程序中,主函数调用了LineMax函数,实现在N行M列的二维数组中,找出每一行上的最大值。 请填空。 #define N 3 #define M 4 void LineMax(int x[N][M]) int i,j,P; for(i=0;i<N;i++) p=0; for(j=1;j<M;j++) if(x[i][p]<x[i][j]) 【9】 ; printf("The max value in line %d is %d/n",i, 【10】 ); main() int x[N][M]=1,5,7,4,2,6,4,3,8,2,3,1; 【11】 ;
填空题要求使下列程序输出5个整数,请填空。 for(i=0;i<=______;printf("%d/n",i+=2););
填空题下列给定程序中已建立了一个带头结点的单向链表,请向链表中插入一个整数,使插入后的链表仍然有序。
请在标号处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> #include <stdlib.h> #define N
8 typedef struct list { int data;
struct list *next; } SLIST; void
fun(SLIST *P, int m) { SLIST *t, *s; s=(SLIST
*)malloc (sizeof(SLIST)); S->data=______;
t=p->next; while(t!=NULL t=______;} ______ }
SLIST *creatlist(int *a) { SLIST *h, *p, *q; int i;
h=p=(SLIST *) malloc (sizeof(SLIST)); for(i=0; i<N;
i++) { q=(SLIST *) malloc (sizeof(SLIST));
q->data=a[i]; p->next=q; p=q; }
p->next=0; return h; } void
outlist(SLIST *h) { SLIST *p;
p=h->next; if(p==NULL) printf("/nThe list is
NULL! /n"); else { printf("/nHead");
do { printf("->% d", p->data);
p=p->next; } while(p!=NULL);
printf("->End/n"); } }
main() { SLIST *head; int
a[N]={11,12,15,18,19,22,25,29}, n; head=creatlist(a);
printf("/nThe list before inpreeing:/n")
outlist(head); printf("Intput a integer:");
scanf("% d", printf("/n The list afeer
inputting:n"); fun(head, n);
outlist(head); }
填空题设有以下定义和语句,sizeof(a)的值是 【14】 ,sizeof(b)的值是 【15】 。structint day;Char month;int year;a,*b;b=&a;
