第50题 (10.0分) 难度:易 第2章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
功能:1982年我国第三次人口普查,结果全国人口为10.3亿,假
如人口增长率为5%。编写一个程序求在公元多少年总人口
翻了一番。
-------------------------------------------------------*/
#include<stdio.h>
void main()
{
double p1=10.3,p2,r=0.05;
int n=1;
/***********SPACE***********/
p2=p1*【?】;
/***********SPACE***********/
while(p2<=【?】)
{
n++;
/***********SPACE***********/
p2=p2*【?】;
}
/***********SPACE***********/
n=【?】;
printf("%d年人口总数翻了一番,即为%g亿人\n",n,p2);
}
答案:
=======(答案1)=======
(1+r)
=========或=========
(r+1)
=======(答案2)=======
2*p1
=========或=========
p1*2
=======(答案3)=======
(1+r)
=========或=========
(r+1)
=======(答案4)=======
n+1982
=========或=========
1982+n
第51题 (10.0分) 难度:中 第2章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
功能:输入3个数a,b,c,按从小到大的顺序输出。
-------------------------------------------------------*/
#include <stdio.h>
main()
{
void swap(int *p1, int *p2);
int n1,n2,n3;
int *pointer1,*pointer2,*pointer3;
printf("please input 3 number:n1,n2,n3:");
scanf("%d,%d,%d",&n1,&n2,&n3);
pointer1=&n1;
pointer2=&n2;
pointer3=&n3;
/***********SPACE***********/
if(【?】) swap(pointer1,pointer2);
/***********SPACE***********/
if(【?】) swap(pointer1,pointer3);
/***********SPACE***********/
if(【?】) swap(pointer2,pointer3);
printf("the sorted numbers are:%d,%d,%d\n",n1,n2,n3);
}
/***********SPACE***********/
void swap(【?】)
int *p1,*p2;
{
int p;
p=*p1;*p1=*p2;*p2=p;
}
答案:
=======(答案1)=======
n1>n2
=========或=========
n2<n1
=========或=========
*pointer1>*pointer2
=========或=========
*pointer2<*pointer1
=======(答案2)=======
n1>n3
=========或=========
n3<n1
=========或=========
*pointer1>*pointer3
=========或=========
*pointer3<*pointer1
=======(答案3)=======
n2>n3
=========或=========
n3<n2
=========或=========
*pointer2>*pointer3
=========或=========
*pointer3<*pointer2
=======(答案4)=======
p1,p2
第52题 (10.0分) 难度:易 第1章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
功能:下面的程序是求1!+3!+5!+……+n!的和。
-------------------------------------------------------*/
#include <stdio.h>
main()
{
long int f,s;
int i,j,n;
/***********SPACE***********/
【?】;
scanf("%d",&n);
/***********SPACE***********/
for(i=1;i<=n; 【?】)
{
f=1;
/***********SPACE***********/
for(j=1; 【?】;j++)
/***********SPACE***********/
【?】;
s=s+f;
}
printf("n=%d,s=%ld\n",n,s);
}
答案:
=======(答案1)=======
s=0
=======(答案2)=======
i+=2
=========或=========
i=i+2
=========或=========
i++,i++
=======(答案3)=======
j<=i
=========或=========
i>=j
=========或=========
j<i+1
=========或=========
i+1>j
=======(答案4)=======
f=f*j
=========或=========
f=j*f
=========或=========
f*=j
第53题 (10.0分) 难度:易 第1章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
题目:从键盘键盘输入3个整数,然后找出最小的数并输出。
例如:输入"10,41,31",
输出 "三个数是:10,41,31.最小数是:10."。
-------------------------------------------------------*/
#include <stdio.h>
#include <conio.h>
main()
{
int a, b, c, min;
printf("请输入三个整数:\n");
/***********SPACE***********/
【?】("%d,%d,%d",&a, &b, &c);
printf("三个数是:%d,%d,%d.", a, b, c);
/***********SPACE***********/
if (【?】) min=b; else min=a;
if (min > c) min=c;
/***********SPACE***********/
printf("最小数是:%d.", 【?】);
}
答案:
=======(答案1)=======
scanf
=======(答案2)=======
a>b
=========或=========
a>=b
=========或=========
b<a
=========或=========
b<=a
=======(答案3)=======
min
第54题 (10.0分) 难度:易 第1章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
题目:计算两个正数数n 和 m(m<1000)之间所有数的和。n和m从
键盘输入。
例如,输入"1,100",输出"1到100之间所有数的和是:5050。"
-------------------------------------------------------*/
#include <stdio.h>
#include <conio.h>
main()
{
int i,n,m;
long sum=0;
printf("请输入两个正整数:n,m\n");
/***********SPACE***********/
scanf("%d,%d",【?】 );
/***********SPACE***********/
for(i=n;【?】; i++)
{
/***********SPACE***********/
sum = sum+【?】;
}
printf("%d到%d之间所有数的和是:%ld\n", n, m, sum);
}
答案:
=======(答案1)=======
&n,&m
=======(答案2)=======
i<=m
=========或=========
m>=i
=========或=========
i<m+1
=========或=========
i<1+m
=========或=========
m+1>i
=========或=========
1+m>i
=======(答案3)=======
i
第55题 (10.0分) 难度:易 第1章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
题目:请输入一个大于100的正整数a,将a的百位、十位和个位依
次放在b的个位、十位和百位上。
例如:输入"321",输出"结果是:123"。
-------------------------------------------------------*/
#include <conio.h>
#include <stdio.h>
main ()
{
int a,b;
printf ("请输入一个大于100的正整数:");
/***********SPACE***********/
【?】("%d", &a);
/***********SPACE***********/
b=(【?】)*100 + ((a/10)%10)*10 + (a/100)%10;
/***********SPACE***********/
printf ("结果是: 【?】\n", b);
}
答案:
=======(答案1)=======
scanf
=======(答案2)=======
a%10
=======(答案3)=======
%d
第56题 (10.0分) 难度:易 第1章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
题目:打印出1~1000中满足个位上的数字、十位上的数字和百位
上的数字都相等的所有三位数。
本题输出"111,222,333,444,555,666,777,888,999, "
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int i,g, s, b;
/***********SPACE***********/
for (【?】; i<=1000; i++)
{
/***********SPACE***********/
g=【?】;
s=(i/10)%10;
/***********SPACE***********/
b=(【?】)%10;
if(g==s && s==b)
printf("%d,",i);
}
}
答案:
=======(答案1)=======
i=1
=======(答案2)=======
i%10
=======(答案3)=======
i/100
第57题 (10.0分) 难度:易 第2章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
功能:已知X、Y、Z分别表示0~9中不同的数字,编程求出使算式
XXXX+YYYY+ZZZZ=YXXXZ成立时X、Y、Z的值,并要求打印该
算式。
-------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
main()
{
int x,y,z;
/***********SPACE***********/
for(x=0;【?】;x++)
for(y=0;y<10;y++)
{
if(y==x) continue;
for(z=0;z<10;z++)
{
/***********SPACE***********/
if(z==x【?】z==y) continue;
/***********SPACE***********/
if(1111*(x+y+z)==【?】+1110*x+z)
{
printf("x=%d,y=%d,z=%d\n",x,y,z);
/***********SPACE***********/
printf("%d+%d+%d=%d\n",1111*x,1111*y,1111*z,【?】);
exit(0);
}
}
}
}
答案:
=======(答案1)=======
x<10
=========或=========
10>x
=======(答案2)=======
||
=======(答案3)=======
10000*y
=========或=========
y*10000
=======(答案4)=======
10000*y+1110*x+z
=========或=========
10000 * y + 1110 * x + z
第58题 (10.0分) 难度:较难 第2章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
功能:计算一元二次方程的根。
-------------------------------------------------------*/
#include <stdio.h>
/***********SPACE***********/
#include 【?】
main()
{
double x1,x2,imagpart;
float a,b,c,disc,realpart;
scanf("%f%f%f",&a,&b,&c);
printf("the equation");
/***********SPACE***********/
if(【?】<=1e-6)
printf("is not quadratic\n");
else
disc=b*b-4*a*c;
if(fabs(disc)<=1e-6)
printf("has two equal roots:%-8.4f\n",-b/(2*a));
/***********SPACE***********/
else if(【?】)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf("has distinct real roots:%8.4f and %.4f\n",x1,x2);
}
else
{
realpart=-b/(2*a);
imagpart=sqrt(-disc)/(2*a);
printf("has complex roots:\n");
printf("%8.4f=%.4fi\n",realpart,imagpart);
printf("%8.4f-%.4fi\n",realpart,imagpart);
}
}
答案:
=======(答案1)=======
<math.h>
=======(答案2)=======
fabs(a)
=======(答案3)=======
fabs(disc) > 1e-6
=========或=========
1e-6<fabs(disc)
第59题 (10.0分) 难度:易 第2章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
功能:在歌星大奖赛中,有10个评委为参赛的选手打分,分数为
1~100分。选手最后得分为:去掉一个最高分和一个最低分
后其余8个分数的平均值。请编写一个程序实现。
-------------------------------------------------------*/
#include<stdio.h>
void main()
{
int score,i,max,min,sum;
max=-32768;
min=32767;
sum=0;
for(i=1;i<=10;i++)
{
printf("input number %d=",i);
/***********SPACE***********/
scanf("%d",【?】);
sum+=score;
/***********SPACE***********/
if(【?】) max=score;
/***********SPACE***********/
if(【?】) min=score;
}
printf("Canceled max score:%d\nCanceled min score:%d\n",max,min);
/***********SPACE***********/
printf("Average score:%d\n",【?】);
}
答案:
=======(答案1)=======
&score
=======(答案2)=======
score>max
=========或=========
max<score
=======(答案3)=======
score<min
=========或=========
min>score
=======(答案4)=======
(sum-max-min)/8
=========或=========
(sum -max - min )/8
第60题 (10.0分) 难度:易 第94章
/*-------------------------------------------------------
【程序填空】
---------------------------------------------------------
说明:下面程序的功能是打印出所有的“水仙花数”,请填写
程序所缺内容。
注:水仙花数是指一个三位数的各位数字的立方和是这个数本身。
-------------------------------------------------------*/
#include"stdio.h"
void f( int n)
{
int i,j,k;
i=n/100;
/***********SPACE***********/
j=【?】;
k=n%10;
/***********SPACE***********/
if(【?】)
{
printf("%5d\n",n);
}
}
void main()
{
void f(int n);
int i;
for(i=100;i<1000;i++)
f(i);
}
答案:
=======(答案1)=======
n/10%10
=========或=========
n%100/10
=======(答案2)=======
i*100 + j*10 + k == i*i*i + j*j*j + k*k*k
=========或=========
n == i*i*i + j*j*j + k*k*k