填空题以下程序的运行结果是______。 #include<stdio.h> long fb(int g) switch(g) case 0:return 0; case 1: case 2: return 1; return(fib(g-1)+fib(g-2)); main() long k; k=fib(5); printf("k=%51d/n", k);
填空题围绕山顶一圈有N个山洞,编号为0、1、2、3、……、N-1,有一只狐狸和一只兔子在洞中居住。狐狸总想找到兔子并吃掉它,它的寻找方法是先到第一个洞(即编号为0的洞)中找;再隔1个洞,即到编号为2的个洞中找;再隔2个洞,即到编号为5的洞中找;下次再隔3个洞;即到编号为9的洞中找;……。若狐狸找一圈,请为兔子指出所有不安全的洞号。程序中用a数组元素模拟一个洞,数组元素的下标即为洞号,数组元素中的值为0时,表示该洞安全,为1时表示该洞不安全。若形参n的值为30时,不安全的洞号是0、2、5、9、14、20、27。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#define N 100
void fun(int*a,int n)
{int i,t;
for(i=0;i<n;i++)
/*********found*********/
a[i]=______;
i=0;
/*********found*********/
______=1;
while(i<n)
{a[i]=1;
t++;
/*********found*********/
i=______;
}
}
main()
{int a[N],i,n=30;
fun(a,n);
for(i=0;i<n;i++)
if(a[i]==1)
printf("不安全的洞号是:%d/n",i);
}
填空题结构变量的成员如果是基本类型数据,可以以“结构变量名.成员名”的形式参加各种运算,而结构变量一般不能直接参加各种运算,但取地址和______运算除外。
填空题下列给定程序中函数fun的功能是:将tt所指字符串中的小写字母全部改为对应的大写字母,其他字符不变。 例如,若输入“Ab,cD”,则输出“AB,CD”。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构! 试题程序: #include<conio.h> #inctude<stdio.h> #include<string.h> char*fun(char tt[]) int i; for(i=0;tt[i];i++) /*********found*********/ if((tt[i]>='a')||(tt[i]<='z')) /*********found*********/ tt[i]+=32; return(tt); void main() char tt[81]; printf("/nPlease enter a string:"); gets(tt); printf("/nThe result string is:%s/n",fun(tt);
填空题有以下程序 main() int n=0,m=1,x=2; if(!n)x-=1; if(m)x-=2; if(x)x-=3; printf("%d/n",x); 执行后输出结果是 【9】 。
填空题请补充函数fun(),该函数的功能是:把从键盘输入的3个整数按从小到大输出。
例如:输入“33 78 25”,结果输出“25 33 78”。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的横线上填入所编写的若干表达式或语句。
试题程序:
# include<stdio. h>
# include<conio. h>
main()
{
int x,y, z,t;
clrscr ();
printf ("Input x, y, z/n");
scanf ("%d%d%d",
if({{U}} {{U}} {{/U}} {{/U}})
{
t=x;
x=y;
y=t;
}/*变换x, y的值*/
if({{U}} {{U}} {{/U}} {{/U}})
t=z;
z=x;
x=t;
}/*交换x, z 的值*/
if({{U}} {{U}} {{/U}} {{/U}})
{
t=y;
y=z;
z=t;
}/*变换 z, y 的值*/
printf("******the result*******/n");
printf("from small to big: %d %d %d/n",
x, y, z);
}
填空题下面的函数fun的功能是将形参x的值转换成二进制数,所得二进制数的每一位放在一维数组中返回,二进制的最低位放在下标为0的元素中,其他依次类推,请填空。
fun(int x,int b[])
{ int k=0,r;
do {
r=x%{{U}} 【13】 {{/U}};
b[k++]=r;
x/={{U}} 【14】 {{/U}};
}while(x);}
填空题下面程序的功能是:计算1~10之间的奇数之和与偶数之和,请填空。
#include<stdio.h>
main()
{ int a,b,c,i;
a=c=0;
for(i=0;i<=10;i+=2)
{a+=i;
{{U}} {{U}} {{/U}} {{/U}};
c+=b; }
printf("偶数之和=%d/n",a);
printf("奇数之和=%d/n",c-11);}
填空题以下程序通过函数指针p调用函数fun,请在填空栏内写出定义变量p的语句。
void fun(int x,int * y)
{……}
main()
{ int a=10,b=20;
{{U}} {{U}} {{/U}} {{/U}}; /*定义变量p*/
p=fun;p(
}
填空题下列程序段的运行结果是______。 char str[]="ABCD",*p=str; printf("%d/n",*(p+3));
填空题下列程序的功能是计算机平均成绩并统计90分以上的人数。
main ( )
{ int n,m;
float grade, average;
average=n=m={{U}} 【13】 {{/U}};
while({{U}} 【14】 {{/U}})
{ scanf("%f",
if (grade<0) break;
m++;
average+=grade;
if (grade<90){{U}} 【15】 {{/U}};
m++;
)
if(n) printf("%.2f %d/n",average/n,m);
}
填空题在一个容量为15的循环队列中,若头指针front=6,尾指针rear=9,则该循环队列中共有______个元素。
填空题有以下程序
#include
main()
{ int i,j,a[][3]={1,2,3,4,5,6,7,8,9};
for(i=0;i<3;i++)
for(j=i;j<3;j++) printf(“%d%,a[i][j]);
printf("/n");
}
程序运行后的输出结果是 【 】 。
填空题以下程序运行后的输出结果是______。
#include<stdio.h>
main()
{ int x=20;
printf("%d", 0<x<20);
printf("%d/n", 0<x
}
填空题以下程序的运行结果是:{{U}} {{/U}}。 #include <stdio.h> #include <string.h> char *ss(char *s) return s+strlen(s)/2; main() char *p,*str="abcdefgh"; p=ss(str);printf("%s//n",p);
填空题以下程序运行后的输出结果是______ 。main() int x=1,y=0, a=0,b=0; switch (x) case 1: switch (y) case 0:a++;break; case 1:b++;break; case 2: a++; b++; break; printf("%d %d/n", a, B) ;
填空题请补充函数fun,其功能是:计算并输出给定10个数的方差:例如,给定的10个数为15.0,19.0,16.0,15.0,18.0,12.0,15.0,11.0,10.0,16.0,输出为s=2.758623。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include<stdio.h>#include<math.h>doublefun(doublex[10])inti;doubleavg=0.0;doublesum=0.0;doubleabs=0.0;doublesd;for(i=0;i<10;i++)【1】;avg=sum/10;for(i=0;i<10;i++)【2】;sd=【3】;returnsd;main()doubles,x[10]=15.0,19.0,16.0,15.0,18.0,12.0,15.0,11.0,10.0,16.0;inti;printf("/nTheoriginaldatais:/n");for(i=0;i<10;i++)printf("%6.1f",x[i]);printf("/n/n");s=fun(x);printf("s=%f/n/n",s);
填空题strcat函数的作用是 【15】 。
填空题请补充函数fun(),该函数的功能是:按行统计N×N维矩阵元素中的最大值(均为整数),并把这些值按从小到大的顺序保存在数组b中。矩阵的维数在主函数中输入,并赋予随机数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 20
void fun({{U}} 【1】 {{/U}})
{
int i j;
int t;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if({{U}} 【2】 {{/U}})
b[i]=a[i][j];
for(i=0;i<n;i++)
{
for(j=0;i<n;j++)
if({{U}} 【3】 {{/U}})
{
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
main()
{
int a[N][N];
int b[N];
int n;
int i,j;
clrscr();
printf("*****Input the dimension of array N*****/n");
scanf("%d",&n);
printf("*****The array *****/n");
for(i=0;i<n;i++)
{
for(j=0;i<n;j++)
{
a[i][j]=rand()%20;
while(a[i][j]==0)
a[i][j]=rand()%30;
printf("%4d",a[i][j]);
}
printf("/n/n");
}
for(i=0;i<n;i++)
b[i]=0;
fun(a,b,n);
printf("***** THE RESULT *****/n");
for(i=0;i<n;i++)
printf("%d",b[i]);
}
填空题有以下程序,请在【12】处填写正确语句,使程序可正常编译运行。
#include
【12】 ;
main()
{ double x,y,(*p)();
scanf("%lf%lf",
p=avg;
printf("%f\n",(*p)(x,y));
}
double avg(double a,double B)
{return((a+B)/2);}