填空题若有以下程序
main( )
{ int p,a=5;
if(p=a!=0)
printf("%d/n",p);
else
printf("%d/n",p+2);
}
执行后输出结果是【 】。
填空题请补充main函数,该函数的功能是求方程ax2+bx+c=0的两个实数根。方程的系数a、b、c从键盘输入,如果判别式 (disc=b2-4ac)小于0,则要求重新输入a、b、c的值。 例如,当a=1,b=2,c=1时,方程的两个根分别是x1=-1.00, x2=-1.00。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include"math.h" #include <stdio.h> main() { float a,b,C,disc,X1,x2; clrscr(); do { printf("Input a,b,C:"); scanf("%f,%f,%f",&a,&b,ac); disc=b*b-4*a*c; if(disc<0) printf("disc=%f/n Input again! /n",disc); }while({{U}} 【1】 {{/U}}); printf("****+* the result *+*****/n"); x1={{U}} 【2】 {{/U}}; x2={{U}} 【3】 {{/U}}; printf("/nx1=%6.2f/nx2=%6.2f/n",x1/x2); }
填空题语句printf("%f/n",13.0*(1/5));的输出结果为 【10】 。
填空题为了使下面程序能够正确运行,程序的第2行应填写的内容是
__①__
,当输入的数值为66和99时,该程序输出的结果是
__②__
。
#include<stdio.h>
__①__
int main()
{
double x1, x2;
scanf(:%lf, %lf",
printf("%lf/n", max(x2, x1));
return 0;
}
double max(double y1, double y2)
{
return(y1>y2?y1-y2:y2-y1);
}
填空题下面程序的运行结果是______
#indude <stdio.h>
main()
{int Y,a;
y=2, a=1;
while(y--!=-1)
{do{a*=y; a++;} while(y--);}
printf("%d, %d", a, y);}
填空题请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则 str2=“cegi”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #define LEN 80 main() char str1[LEN],str2 [LEN]; char *p1=str1,*p2=str2; int i=0,j=0; clrscr(); printf("Enter the string:/n"); scanf( 【1】 ); printf("***the origial string***/n"); while(*(p1+j)) printf(" 【2】 ",*(p1+j)); j++; for(i=0;i<j;i+=2) *p2++=*(str1+i); *p2='/0'; printf("/nThe new string is:%s/n", 【3】 );
填空题下列给定程序中,函数fun()的功能是:实现两个整数的交换。例如给a和b分别输入60和65,输出为:a=65 b=60 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序; #include<stdio.h> #include <conio.h> /*************found**************/ void fun(int a,b) int t; /*************found**************/ t=b;b=a;a=t; main() int a,b; clrscr(); printf("Enter a, b: "); scanf("%d%d", fun( printf("a=%d b=%d/n ", a,b);
填空题若有语句“doube x=17;int y;”,当执行“y=(int)(x/5)%2;”之后y的值为______。
填空题请补充函数fun(),该函数的功能是:判断某一个年份是否为闰年。
例如,1900年不是闰年,2004是闰年。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
int fun(int n)
{
int flag=0;
if (n%4=0)
{
if ({{U}} 【1】 {{/U}})
flag=1;
}
if ({{U}} 【2】 {{/U}})
flag=1;
return{{U}} 【3】 {{/U}};
}
main()
{
int year;
clrscr();
printf("Input the year:");
scanf("%d",
if (fun(year))
printf("%d is a leap year. /n", year);
else
printf("%d is not a leap year./n",
year);
}
填空题请补充函数proc(),该函数的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。
例如,若一维数组中的数据是:1 1 2 2 2 3 4 4 5 5 6 6 6 7 7 8 10 10。
删除后,数组中的内容应该是:1 2 3 4 5 6 7 8 10。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define M 80
int proc(int arr[], int n)
{
int i, t, j=0;
t=arr[0];
for(i=1; i<n; i++)
if(______)
;
else
{
______;
t=arr[i];
}
arr[j++]=t;
return j;
}
void main()
{
int arr[M]={1, 1, 2, 2, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 10, 10}, i, n=18;
printf("The original data: /n");
for(i=0; i<n; i++)
printf("%4d", arr[i]);
n=proc(arr, n);
printf("/n/nThe data after deleted; /n");
for(i=0; i<n; i++)
printf("%4d", arr[i]);
printf("/n");
}
填空题若有定义int m=5,y=2,则执行表达式y+=y-=m*=y后,y的值为{{U}} 【6】 {{/U}}。
填空题表达式3.5+1/2的计算结果是______。
填空题给定程序中,函数fun的功能是将形参n中,各位上为偶数的数取出,并按原来从高位到低位的顺序组成一个新的数,并作为函数值返回。
例如,从主函数输入一个整数27638496,函数返回值为26846。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdio.h>
unsigned long fun(unsigned long n)
{ unsigned long x=0,s,i;int t;
s=n;
/************found***********/
i=______;
/*************found************/
while(______)
{ t=s%10;
if(t%2==0){
/*************found**********/
x=x+t*i;i=______;
}
s=s/10;
}
return x;
}
main()
{ unsigned long n=-1;
while(n>99999999||n<0)
{ printf("Please input(0<n<100000000):");
scanf("%ld",}
printf("/nThe result is:%ld/n",fun(n));
}
填空题若从键盘输入58,则以下程序输出的结果是 【7】 。 main() int a; scanf("%d",&a); if(a>50)printf("%d",a); if(a>40)printf("%d",a); if(a>30)printf("%d",a);
填空题媒体在计算机领域中的含义,是指存储信息的实体和 【4】 。
填空题给定程序的功能是计算score中m个人的平均成绩aver,将低于aver的成绩放在below中,通过函数名返回人数。 例如,当score=(10,20,30,40,50,60,70,80,90),m=9时,函数返回的人数应该是4,below=10,20,30,40)。 注意:部分源程序已给出。 请勿改动主函数main和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<string.h> int fun(int score[],int m,int below[]) int i,j=0; float aver=0.0: for(i=0;i<m;i++) aver+=score[i]: aver/=(float)m; n=fun(score,9, (2) ); printf("/n Below the average score are:%d/n",n); for(i=0;i<n;i++) for(i=0;i<m;i++) if(score[i]~aver) below[j++]= (1) ; return j; void main() int i,n,below[9]; int score[9]=10,20,30,40,50,60,70,80,90); printf("%d", (3) );
填空题以下程序运行时若从键盘输入:10 20 30<回车>。输出结果是 【6】 。 #include <stdio.h> main() int i=0,j=0,k=0; scanf("%d%*d%d",
填空题函数voidfun(float*sn,intn)的功能是:根据以下公式计算s,计算结果通过形参指针sn传回;n通过形参传入,n的值大于或等于0。请填空。voidfun(float*sn,intn)floats=0.0,w,f=-1.0;inti;for(i=0;i<=n;i++)f=【13】*f;w=f/(2*i+1);s+=w;【14】=s;
填空题下面程序的功能是将一个字符串str的内容倒序。请填空。 #include<string.h> main( ) int i,j, (14) ; char str[]="1234567"; for(i=0,j=strlen(str) (15) ;i<j;i++,j--)k=str[i];str[i]=str[j];str[j]=k; printf("%s/n", str):
填空题请补充main函数,该函数的功能是:计算每个学生成绩的平均分,并把结果保存在数组bb中。
例如,当scorer[N][M]={{83.5,82,86,65,67),{80,91.5,84, 99,95){90.5,95,86,95,97}}时,三个学生的平均分为76.7 89.9 92.7。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若千表达式或语句。
试题程序:
#include<stdio.h>
#define N 3
#define M 5
main()
{
int i,j;
static float score[N][M]={{83.5,82,86,
65,67},{80,91.5,84,99,95},{90.5,95,
86,95,97}};
float bb[N];
clrscr();
for(i=0;i<N;i++)
{{U}}【1】{{/U}};
for(i=0;i<N;i++)
{
for (j=0; j<M; j++)
{{U}}【2】{{/U}};
bb [i]/=M;
}
for (i=0; i<N; i++)
print f (" knstudent %d/t average
=%5.1f",i+l,bb[i]);
}
