Dotcpp  >  试卷列表  >  全国计算机等级考试《二级C语言程序设计》模拟试题(二)

全国计算机等级考试《二级C语言程序设计》模拟试题(二)


第1题

下列叙述中正确的是( )。

共 1 分 

第2题

下列各序列中不是堆的是( )。

共 1 分 

第3题

设循环队列为Q(1:m),其初始状态为front=rear=m。经过一系列入队与退队运算后,front=15,rear=20。现要在该循环队列中寻找最大值的元素,最坏情况下需要比较的次数为(   )。

共 1 分 

第4题

定义无符号整数类为UInt,下面可以作为类UInt实例化值的是( )

共 1 分 

第5题

一个栈的初始状态为空。现将元素1、2、3、4、5、A、B、C、D、E依次入栈,然后再依次出栈,则元素出栈的顺序是( )。

共 1 分 

第6题

某系统结构图如下图所示,该系统结构图的最大出扇数是( )。

结构

共 1 分 

第7题

软件设计中模块划分应遵循的准则是( )。

共 1 分 

第8题

在数据库中,数据模型包括数据结构、数据操作和( )。

共 1 分 

第9题

在数据库设计中,描述数据间内在语义联系得到E-R图的过程属于( )。

共 1 分 

第10题

一个运动队有多个队员,一个队员仅属于一个运动队,一个队一般都有一个教练,则实体运动队和队员的联系是( )。

共 1 分 

第11题

以下叙述中错误的是()。

共 1 分 

第12题

C源程序中不能表示的数制是()。

共 1 分 

第13题

关于C语言标识符,以下叙述错误的是()。

共 1 分 

第14题

若有定义语句:int x=10;则表达式x-=x+x的值为( )。

共 1 分 

第15题

以下叙述中正确的是( )。 

共 1 分 

第16题

以下合法的转义字符是()。

共 1 分 

第17题

设有定义:double x=2.12;,以下不能完整输出变量x值的语句是(   )。

共 1 分 

第18题

设有定义:int a,b;  float x,y;则以下选项中对语句所作的注释叙述错误的是( )。

共 1 分 

第19题

有以下程序

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
main()
{
int  x=1, y=0;
if (!x) y++;
else if (x==0)
if (x) y+=2;
else y+=3;
printf("%d\n", y);
}

程序运行后的输出结果是( )。

共 1 分 

第20题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
main()
{
int a,b;
for(a=0; a<3; a++)
{
scanf("%d", &b);
switch(b)
{
defaultprintf("%d,", ++b);
case 1: printf("%d,", ++b);
case 2: printf("%d,", ++b);
}
}
}

执行时输入:1 2 3 <回车>,则输出结果是( )。

共 1 分 

第21题

有以下程序

1
2
3
4
5
6
7
#include  <stdio.h>
main()
{
int a=-1, b=-1;
for(; ++a;)++b;
printf("%d,%d\n", a, b);
}

程序运行后的输出结果是( )。

共 1 分 

第22题

以下叙述中正确的是( )。

共 1 分 

第23题

有以下程序

1
2
3
4
5
6
7
8
#include <stdio.h>
main()
{
int a=1,b=1;
while(a--)
b--;
printf("%d,%d\n", a,b);
}

程序的运行结果是( )。

共 1 分 

第24题

以下数组定义中错误的是(   )。

共 1 分 

第25题

有以下程序

1
2
3
4
5
6
7
8
#include   <stdio.h>
main()
{
char *p1 = 0;
int *p2 = 0;
float *p3 = 0;
printf("%d,%d,%d\n"sizeof(p1), sizeof(p2), sizeof(p3));
}

程序运行后的输出结果是( )。

共 1 分 

第26题

字符数组a和b中存储了两个字符串,判断字符串a和b是否相等,应当使用的是()。

共 1 分 

第27题

C语言程序的模块化通过以下哪个选项来实现?( )

共 1 分 

第28题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
int m1(int x,int y)
{
return x<=y ? x :y;
}int m2(int x,int y)
{
return x<=y ? y :x;
}int fun(int a,int b)
{
return a+b;
}
main()
{
int x=2,y=3,z=1;
printf("%d\n", fun(m1(x,y),m2(y,z)));
}

程序的运行结果是( )。

共 1 分 

第29题

以下叙述正确的是( )。

共 1 分 

第30题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int f(int x);
main()
{
int n=1,m;
m=f(f(f(n)));
printf("%d\n",m);
}int f(int x)
{
return x*2;
}

程序运行后的输出结果是( )。

共 1 分 

第31题

有以下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
void fun(int a[],int n)
{
int i,t;
for(i=0;i<n/2;i++)
{
t=a[i];
a[i]=a[n-1-i];
a[n-1-i]=t;
}
}
main()
{
int k[10]={1,2,3,4,5,6,7,8,9,10},i;
fun(k,5);
for(i=2;i<8;i++)printf("%d",k[i]);
printf("\n");
}

程序运行的结果是( )。

共 1 分 

第32题

若有定义语句:

1
int year=2009,*p=&year;,

以下不能使用变量year 中的值增至2010的语句是( )。

共 1 分 

第33题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <stdlib.h>
void  fun( double  *p1,double  *p2,double  *s)
{
s = (double *)calloc( 1,sizeof(double) );
*s = *p1 + *( p2+1 );
}
main()
{
double  a[2] = { 1.1, 2.2 }, b[2] = { 10.0, 20.0 }, *s=a;
fun( a, b, s );
printf"%5.2f\n", *s);
}

程序的输出结果是( )。

共 1 分 

第34题

以下叙述中错误的是(   )。

共 1 分 

第35题

设p是指针变量,语句p = NULL;等价于( )。

共 1 分 

第36题

以下叙述中正确的是( )。

共 1 分 

第37题

若要使用C数学库中的sin函数,需要在源程序的头部加上#include <math.h>关于引用数学库,以下叙述正确的是( )。

共 1 分 

第38题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
typedef struct stu
{
char name[10];
char gender;
int score;
} STU;
void f(STU a, STU *b)
{
*b = a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{
STU a={"Zhao"'m', 290}, b={"Qian"'f', 350};
f(a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}

程序运行后的输出结果是( )。

共 1 分 

第39题

下面结构体的定义语句中,错误的是(   )。

共 1 分 

第40题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
typedef struct {int b, p;} A;
void f(A c)
{
int j;
c.b+=1;
c.p+=2;
}void main()
{
int i;
A a={1,2};
f(a);
printf("%d,%d\n", a.b, a.p);
}

程序运行后的输出结果是( )。

共 1 分 

第41题

给定程序中,函数fun功能是:找出100~999之间(含100和999)所有整数中各位上数字之和为x(x为一正整数)的整数.然后输出;符合条件的整数个数作为函数值返回。
例如,当x值为5时,l00~999之间各位上数字之和为5的整数有:104、113、122、131、140、203、212、221、230、302、311、320、401、410、500。共有15个。当x值为27时,各位数字之和为27的整数是:999。只有1个。
请在程序的下划线处填入正确的内容并把下划线删除.使程序得出正确的结果。
注意:

源程序存放在考生文件夹下的BLAIIK1.C中。
不得增行或删行.也不得更改程序的结构!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**********code.c**********/
#include <stdio.h>
int fun(int x)
{
int n, s1, s2, s3, t;
n=0;
t=100;
while(t<=①______)
{
s1=t%10;
s2=(②______)%10;
s3=t/100;
if(s1+s2+s3==③______)
{
printf("%d ",t);
n++;
}
t++;
}return n;
}
void main()
{
int x=-1;
while(x<0)
{
printf("Please input(x>0): ");
scanf("%d",&x);
}
printf("\nThe result is: %d\n",fun(x));
}
/**********-code.c**********/
共 20 分 

第42题

绐定程序MODI1.C中函数fun的功能是:从低位开始取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。高位仍在高位,低位仍在低位。
例如,当s中的数为:7654321时,t中的数为:642。
请改正程序中的错误,使它自能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**********code.c**********/
#include <stdio.h>
/**********found**********/
void fun (long s, long t)
{
long sl=10;
s /= 10;
*t = s % 10;
/**********found**********/
while (s < 0)
{
s = s/100;
*t = s%10*sl + *t;
sl = sl * 10;
}
}
main()
{
long  s, t;
printf("\nPlease enter s:");
scanf("%ld", &s);
fun(s, &t);
printf("The result is: %ld\n", t);
}
/**********-code.c**********/
共 40 分 

第43题

学生的记录由学号和成绩组成,N名学生的数据已在主函数中敲入结构体数组s中,请编写函数fun,它的功能是:按分数的高低排列学生的记录,高分在前。
注意:

部分源程序给出如下。请勿改动主函数main和其它函数中
的任何内容,仅在函数fun的花括号中填入你编写的若干语句。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**********code.c**********/
#include <stdio.h>
#define N 16
typedef struct
{
char num[10];
int s;
}STREC;
void fun(STREC a[])
{
STREC tmp;
int i,j;
for(i = 1; i < N; i++)
for(j = 0; j < N-1; j++)
{
/* 请按题目要求,完成一下代码*/
}
}void main()
{
STREC s[N] = {{"GA005",85}, {"GA003",76}, {"GA002",69},
{"GA004",85}, {"GA001",91}, {"GA007",72}, {"GA008",64},
{"GA006",87},
{"GA015",85},{"GA013",91}, {"GA012",64}, {"GA014",91},
{"GA011",66},{"GA017",64}, {"GA018",64}, {"GA016",72}};
int i;
FILE *out;
fun(s);
printf("The data after sorted :\n");
for(i=0;i<N;i++)
{
if((i)%4==0)printf("\n");
printf("%s %4d ",s[i].num,s[i].s);
}
printf("\n");
out = fopen("out.dat","w");
for(i=0;i<N;i++)
{
if((i)%4==0&&i) fprintf(out,"\n");
fprintf(out,"%4d ",s[i].s);
}
fprintf(out,"\n");
fclose(out);
}

参考答案:

1
2
3
4
5
6
if(a[i].s<a[j].s)
{
tmp=a[j];
a[j]=a[i];
a[i]=tmp;
}
共 0 分