资源描述
第一学期
《C语言程序设计》模拟考试题(C卷) 考试说明:
1 .考试时间为90分钟,试卷总分值100分。
2 .考题包括两局部,选择题30小题共45分,编程题5小题共55分。
3 .做选择题请直接双击D盘考生试题文件夹下的“做选择题”程序,并在 该环境下进行操作,全部做完后按“退出”。
4 .做编程题时,按题目要求在Visual C++环境下进行操作,并把源程序文 件保存到题目指定的文件夹中。
5 .全部试题完成后,保存好文件,关闭所有窗口后进行交卷。请注意:交 卷操作只能执行一次。
编程题:
1 .编程输入X的值,求y=x2°-2*x%5的值,程序文件命名为pl. C,保存到 D:\C文件夹中。
2 .编程输入年份,判断它是否是闰年(两个条件:能被4整除但不能被100 整除或者能被400整除),程序文件命名为p2.c,保存到D:\C文件夹中。
3 .编程求出100〜999的所有的水仙花数(所谓“水仙花数”是指一个3位 数,其各位数字立方和等于该数本身),程序文件命名为p3.c,保存到D:\C文件夹中。
4 .编程求出1〜100之间的全部素数。程序文件命名为p4.c,保存到D:\C 文件夹中。
5 .使用数组编写程序,输入5个学生6门课程的成绩,输出5个学生中平均 分最高的学生的平均分。程序文件命名为p5.c,保存到D:\C文件夹中。
参考答案
选择题参考答案
1
2
3
4
5
6
7
8
9
10
C
A
D
B
A
B
B
A
C
A
11
12
13
14
15
16
17
18
19
20
B
D
A
A
B
B
C
B
B
D
21
22
23
24
25
26
27
28
29
30
A
C
A
D
B
B
D
D
B
D
编程题参考程序:
pl. C :
ftinclude <stdio. h>ftinclude <math.h>
void main (){
float x, y;printf (〃请输入x的值:〃);
scanf (〃%f 〃, &x);y=pow (x, 20)-2*pow(x, 10)+5;
printf(〃y=%f\n〃,y);}
参考程序:
p2. c:
ftinclude <stdio.h>void main ()
(int year;
printf (〃请输入一个年份:〃);scanf (〃%d〃, &year);
if((year%4==0 && year%100!=0)| |(year%400==0)) printf (〃%d 是闰年! \n〃,year);else
printf (〃%d 不是闰年! \n〃,year);)
参考程序:
p3. c:
ftinclude <stdio.h>ftinclude <math.h>
void main ()(
int i, j, k, n;printf (〃水仙花数是:〃);
for (n=100;n<1000;n++)i=n/100;
j=(n-i*100)/10;k=n-i*100-j*10;
if (n==pow(i, 3) +pow(j, 3) +pow(k, 3)) printf (〃%d 〃, n);)
printf (〃\n〃);}
参考程序:
p4. c:
ttinclude <stdio. h>ftinclude <math.h>
void main (){ int m, k, i, n=0;
for (m=l;m<=100;m++){ k=sqrt(m);
for (i=2;i<=k;i++)if (m%i—0)
break;
if (i>=k+l)printf (〃%d 〃, m);
)printf(〃\n〃);
)参考程序:
programs, c:
ttinclude <stdio. h>void main ()
{double score[5][7], sum, max=0;
int i, j;for (i=0;i<5;i++)
(printf (〃请输入第%d个学生的6门课程的成绩:〃,i+1);
for(j=0;j<6;j++)scanf(〃%lf〃, &score[i] [j]);
}for(i=0;i<5;i++)
(sum=0;
for (j=0;j<6;j++) sum=sum+score[i] [j];score[i][6]=sum/6. 0;
for (i=0;i<5;i++)(
if (score[i][6]>max)
max=score[i] [6];
printf (〃5个学生中平均分最高的学生的平均分为:%lf\n〃, max);
展开阅读全文