填空题执行以下程序后,输出#号的个数是{{U}} 【10】 {{/U}}。
#include <studio.h>
main()
{int i,j;
for(i=1;i<5;i++)
for(j=2;j<=i;j++)putchar('#');
}
填空题若有如下定义,则该数组的第一维大小为______。
int b[][4]={1,2,3,4,5,6,7,8,9);
填空题有以下定义和语句,则sizeof(a)的值是{{U}} 【13】 {{/U}},而sizeof(a.share)的值是{{U}} 【14】 {{/U}}。
struct date
{ int day;
int mouth;
int year;
union {int share1;
float share2;
}share;
}a;
填空题己定义char ch='$';int i=l,j;,执行j=!ch &&i i++以后,i的值为{{U}} 【11】 {{/U}}。
填空题N个有序整数数列已放在一维数组中,给定的下列程序中,函数fun()的功能是:利用折半查找法查找整数m在数组中的位置。若找到,则返回其下标值;反之,则返回“Not be found!”。 折半查找法的基本算法是:每次查找前先确定数组中待确定的范围:low和high(low<high),然后把m与中间位置(mid)中元素的值进行比较。如果m的值大于中间位置元素中的值,则下一次的查找范围放在中间位置之后的元素中;反之,下次查找范围落在中间位置之前的元素中,直到low>high,查找结束。 [注意] 部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。 [试题源程序] #include <stdio.h> #define N 10 int fun(int a[],int m) int low=0, high=N-1, mid; while(low<=high) mid= (1) ; if(m<a[mid]) high= (2) ; eise if(m>a[mid]) low=mid+1; else return(mid); (3) (-1); main() int i, a[N]=(-3, 4, 7, 9, 13, 24, 67, 89, 100, 180), k, m; printf("a数组中的数据如下: "); for(i=0; i<N; i++); printf("%d", a[i]); printf("Enter m: "); scanf("%d", &m); k=fun(a, m); if(k>=0) printf("m=%d, index=%d/n", m, k)); else printf("Not be found/n");
填空题设函数findbig已定义为求3个数中的最大值,以下程序将利用函数指针调用findbig函数。请填空。
main()
{ int findbig(int,int,int);
int(*f)(),x,y,z,big;
f={{U}} 【15】 {{/U}}。
scanf("%d %d %d",
big=(*f)(x,y,z);
printf("big=%d/n",big);
}
填空题有以下程序:
#include <stdio.h>
main()
{ int t=1,i=5;
for(;i>=0;i--) t*=i;
printf("%d/n",t);
}
执行后的输出结果是{{U}} 【8】 {{/U}}。
填空题以下程序的输出是{{U}} 【7】 {{/U}}。
main()
{
char str1[]=How do you do",*p=strl;
strcpy(str1+strlen(str1)/2"es she");
pfinff("%s/n",p1);
}
填空题以下条件表达式可计算:1+|a|的值,请填空。
a>=0?{{U}} [6] {{/U}}:{{U}} [7] {{/U}}
填空题下列给定的程序中,函数hn()的功能是:为一个偶数寻找两个素数,这两个素数之和等于该偶数,并将这两个素数通过形参指针传回主函数。 请改正函数fun()中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <stdio.h> #include <math.h> void fun(int a, int *b, int *c) int i,j,d,y; for (i=3;i<=a/2;i=i+2) /*************found**************/ y=0; for (j=2;j<=sqrt((double)i);j++) if (i%j==0) y=0; if (y==1) /*************found**************/ d=i-a; for (j-2;j<=sqrt((double)d); j++) if (d%j==0) y=0; if (y=-1) *b=i; *c=d; main () int a,b,c; do printf("/nInput a: "); scanf ("%d", while (a%2); fun (a, printf ("/n/n%d=%d+%d/n", a,b,c);
填空题程序通过定义学生结构体变量,存储了学生的学号、姓名和三门课的成绩。函数fun的功能是将形参a所指结构体变量中的数据赋给函数中的结构体变量b,并修改b中的学号和姓名,最后输出修改后的数据。
例如:a所指变量中的学号、姓名和三门课的成绩依次是:10001、"ZhangSan"、95、80、88,则修改后输出b中的数据应为:10002、"LiSi"、95、80、88。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
#include<string.h>
struct student{
long sno;
char name[10];
float score[3];
};
void fun(struct student a)
{struct student b;int i;
/**********found**********/
b=______;
b.sno=10002;
/**********found**********/
strcpy(______,"LiSi");
printf("/nThe data after modified:/n");
printf("/nNo:%ld Name:%s/nScores:",b.sno,b.name);
/**********found**********/
for(i=0;i<3;i++)printf("%6.2f",b.______);
printf("/n");
}
main()
{struct student s={10001,"ZhangSan",95,80,88};
int i;
printf("/n/nThe original data:/n");
printf("/nNo:%ld Name:%s/nScores:",s.sno,s.name);
for(i=0;i<3;i++)printf("%6.2f",s.score[i]);
printf("/n");
fun(s);
}
填空题请补充函数fun(),该函数的功能是判断一个数的个位数字和百位数字之和是否等于其十位上的数字,是则返回"yes!”,否则返回“no!”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio.h> #include <conlo.h> char *fun(int n) int g,s,b; g=n%l0; s=n/10%10; b= 【1】 ; if((g+b)==s) return 【2】 ; else return 【3】 ; main() int num=0; clrscr(); printf("******Input data*******/n"); scanf("%d",&num); printf("/n/n/n"); printf("******The result*******/n"); printf("/n/n/n%s",fun(num));
填空题请补充main()函数,该函数的功能是:打印出1~10000中满足个位数字的立方等于其本身的所有的数。
本题的结果为:1 64 125 216 729
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main()
int i,k;
system("CLS");
for(i=1;i<10000;i++)
{
k=______;
if(______)
printf("%4d",i);
}
}
填空题下面程序的输出结果是{{U}} 【12】 {{/U}}。
char b[]="ABCD";
main()
{
char b[30];
strcpy(
printf("%s/n",b) ;
}
填空题请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio .h>
#define N 10
main()
{
int bb[N] IN];
iht i,j,n;
clrscr 0;
printf (" /nInput n: /n");
scanf ("%d",
for (i=0; i<n; i++ )
for (j=0; j<n; j++)
{
if({{U}}【1】{{/U}})
bb[i] [j]=l;
else
{{U}}【2】{{/U}};
}
printf(" /n*** the result *** /n");
for (i=0; i<n; i++)
{
printf (" /n/n");
for (j=0; j<n; j++)
printf ("%4d",bb [i] [j ] );
}
}
填空题若变量n中的值为24,则prnt函数共输出{{U}} 【20】 {{/U}}行。
void prnt(int n,int aa [])
{ int i;
for(i=1;i<=n;i++)
{printf("%6d",aa[i]);
if(!(i%5))printf("/n");
}
printf("/n");
}
填空题下列程序的输出结果是______。
#include<stdio.h>
fun()
{ static int a=0;
a+=3;printf("%d",a);
}
main()
{ int cc;
for(cc=1 ;cc<5;cc++)fun();
printf("/n");
}
填空题软件工作三要素包括方法、工具和过程,其中,______支持软件开发的各个环节以及控制和管理。
填空题给定程序中,函数fun的功能是:调用随机函数产生20个互不相同的整数放在形参a所指数组中(此数组在主函数中已置0)。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:
部分源程序在文件BLANK1.C中。不得增行或删行,也不得更改程序的结构!
[试题源程序]
#include<stdlib.h>
#include<stdio.h>
#define N 20
void fun(int*a)
{int i,x,n=0;
x=rand()%20;
/***********found**********/
while(n<______)
{for(i=0;i<n;i++)
/***********found**********/
if(x==a[i])
______;
/***********found**********/
if(i==______)
{a[n]=x;n++;}
x=rand()%20;
}
}
main()
{int x[N]={0},i;
fun(x);
printf("The result:/n");
for(i=0;i<N;i++)
{printf("%4d",x[i]);
if((i+1)%5==0)printf("/n");
}
printf("/n/n");
}
填空题若s是int型变量,且s=8,则s%3+(s+1)%3表达式的值为______。
