Dotcpp  >  试卷列表  >  2022年3月全国计算机等级考试真题(二级C语言)

2022年3月全国计算机等级考试真题(二级C语言)


第1题

下列有关栈论述正确的是( )

共 1 分 

第2题

下列论述中正确的是( )

共 1 分 

第3题

某二叉树共有7个结点,其中叶子结点只有1个,则该二叉树的深度为(假设根结点在第1层)( )

共 1 分 

第4题

在软件开发中,需求分析阶段产生的重要文档是( )

共 1 分 

第5题

构造化程序所规定的基本构造不涉及( )

共 1 分 

第6题

下面描述中错误的是( )

共 1 分 

第7题

负责数据库中查询操作的数据库语言是( )

共 1 分 

第8题

一种教师可讲授多门课程,一门课程可由多种教师讲授,则实体教师和课程间的联系是( )

共 1 分 

第9题

有三个关系R、S和T如下:

2022年3月全国计算机等级考试真题(二级C语言)

则由关系R和S得到关系T的操作是( )

共 1 分 

第10题

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

共 1 分 

第11题

计算机高档语言程序的运营措施有编译执行和解释执行两种,如下论述中正确的是( )

共 1 分 

第12题

如下论述中错误的是( )

共 1 分 

第13题

如下选项中不能用作C程序合法常量的是( )

共 1 分 

第14题

如下选项中可用作C程序合法实数的是( )

共 1 分 

第15题

若有定义语句:int a=3,b=2,c=1;,如下选项中错误的赋值体现式是( )

共 1 分 

第16题

有如下程序段:

1
2
3
char name[20];
int num;
scanf("name=%s num=%d",name,&num);

当执行上述程序段,并从键盘输入:name=Lili num=1001<回车>后,name的值为( )

共 1 分 

第17题

if语句的基本形式是:if(体现式)语句,如下有关“体现式”值的论述中正确的是( )

共 1 分 

第18题

有如下程序:

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

程序运营后的输出成果是( )

共 1 分 

第19题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<stdio.h>
main()
{
    int s;
    scanf("%d",&s);
    while(s>0)
    {
        switch(s)
        {
            case1:printf("%d",s+5);
       case2:printf("%d",s+4); break;
       case3:printf("%d",s+3);
       default:printf("%d",s+1);break;
        }
        scanf("%d",&s);
    }
}

运营时,若输入1 2 3 4 5 0<回车>,则输出成果是( )

共 1 分 

第20题

有如下程序段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int i,n;
for(i=0;i<8;i++)
{
    n=rand()%5;
    switch(n)
    {
        case 1:
   case 3:printf("%d\n",n); break;
   case 2:
   case 4:printf("%d\n",n); continue;
   case 0:exit(0);
    }
    printf("%d\n",n);
}

如下有关程序段执行状况的论述,正确的是( )

共 1 分 

第21题

有如下程序:

1
2
3
4
5
6
7
8
9
#include<stdio.h>
main()
{
    char s[]="012xy\08s34f4w2";
    int i,n=0;
    for(i=0;s[i]!=0;i++)
    if(s[i]>= "0"&&s[i]<= "9")n++;
    printf("%d\n",n);
}

程序运营后的输出成果是( )

共 1 分 

第22题

若i和k都是int类型变量,有如下for语句:

1
2
for(i=0,k=1;k=1;k++)
printf("*****\n");

下面有关语句执行状况的论述中正确的是( )

共 1 分 

第23题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<stdio.h>
main()
{
    char b,c;
    int i;
    b="a";
    c="A";
    for(i=0;i<6;i++)
    {
        if(i%2)putchar(i+b);
   else putchar(i+c);
    }
    printf("\n");
}

程序运营后的输出成果是( )

共 1 分 

第24题

设有定义:double x[10],*p=x;,如下能给数组x下标为6的元素读入数据的正确的语句是( )

共 1 分 

第25题

有如下程序(阐明:字母A的ASCII码值是65)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<stdio.h>
void fun(char *s)
{
    while(*s)
    {
        if(*s%2)
        printf("%c",*s);
   s++;
    }
}
main()
{
    char a[]="BYTE";
    fun(a);
    printf("\n");
}

程序运营后旳输出成果是( )

共 1 分 

第26题

有如下程序段:

1
2
3
4
5
6
7
#include<stdio.h>
main()
{
    
    while(getchar()!="\n");
    
}

如下论述中正确的是( )

共 1 分 

第27题

有如下程序:

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 分 

第28题

若有定义语句:char s[3][10],(*k)[3],*p;,则如下赋值语句正确的是( )

共 1 分 

第29题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<stdio.h>
void fun(char *c)
{
    while(*c)
    {
        if(*c>="a"&&*c<="z")
        *c=*c-("a"-"A");
   c++;
    }
}
main()
{
    char s[81];
    gets(s);
    fun(s);
    puts(s);
}

当执行程序时从键盘上输入Hello Beijing〈回车〉,则程序的输出成果是( )

共 1 分 

第30题

如下函数的功能是:通过键盘输入数据,为数组中的所有元素赋值。

1
2
3
4
5
6
7
8
#include<stdio.h>
#define N 10
void fun(int x[N])
{
    int i=0;
    while(i<N)
    scanf("%d",    );
}

在程序中下划线处应填入的是( )

共 1 分 

第31题

有如下程序:

1
2
3
4
5
6
7
8
#include<stdio.h>
main()
{
    char a[30],b[30];
    scanf("%s",a);
    gets(b);
    printf("%s\n %s\n",a,b);
}

程序运营时若输入:

how are you? I am fine〈回车〉

则输出成果是( )

共 1 分 

第32题

设有如下函数定义:

1
2
3
4
5
6
int fun(int k)
{
    if (k<1) return 0;
    else if(k==1) return 1;
    else return fun(k-1)+1;
}

若执行调用语句:n=fun(3);,则函数fun总共被调用的次数是( )

共 1 分 

第33题

有如下程序:

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

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

共 1 分 

第34题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<stdio.h>
int fun()
{
    static int x=1;
    x*=2;
    return x;
}
main()
{
    int i,s=1;
    for(i=1;i<=3;i++)s*=fun();
    printf("%d\n",s);
}

程序运营后的输出成果是( )

共 1 分 

第35题

有如下程序:

1
2
3
4
5
6
7
#include<stdio.h>
#define S(x) 4*(x)*x+1
main()
{
    int k=5,j=2;
    printf("%d\n",S(k+j));
}

程序运营后的输出成果是( )

共 1 分 

第36题

设有定义:struct {char mark[12];int num1;double num2;}t1,t2;,若变量均已对的赋初值,则如下语句中错误的是( )

共 1 分 

第37题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
12
#include<stdio.h>
struct ord
{
    int x,y;
}
dt[2]={1,2,3,4};
main()
{
    struct ord *p=dt;
    printf("%d,",++(p->x));
    printf("%d\n",++(p->y));
}

程序运营后的输出成果是( )

共 1 分 

第38题

有如下程序:

1
2
3
4
5
6
7
8
9
10
11
#include<stdio.h>
struct S
{
    int a,b;
}
data[2]={10,100,20,200};
main()
{
    struct S p=data[1];
    printf("%d\n",++(p.a));
}

程序运营后的输出成果是( )

共 1 分 

第39题

有如下程序:

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

程序运营后的输出成果是( )

共 1 分 

第40题

设fp已定义,执行语句fp=fopen("file","w");后,如下针对文本文献file操作论述的选项中正确的是( )

共 1 分 

第41题

给定程序中,函数fun的功能是:在形参s所指字符串中寻找与参数c相同的字符,并在其后插入一个与之相同的字符,若找不到相同的字符则函数不做任何处理。

例如,s所指字符串为:baacda,c中的字符为:a,执行后s所指字符串为:baaaacdaa。

请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

注意:源程序存放在考生文件夹下的BLANK1.C中。

不得增行或删行,也不得更改程序的结构!

给定源程序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
void fun(char *s, char c)
{
    int i, j, n;
    for(i=0; s[i]!=___1___ ; i++)
    if(s[i]==c)
    {
        n=___2___ ;
        while(s[i+1+n]!='\0') n++;
        for(j=i+n+1; j>i; j--) s[j+1]=s[j];
        s[j+1]=___3___ ;
        i=i+1;
    }
}
main()
{
    char s[80]="baacda", c;
    printf("\nThe string: %s\n",s);
    printf("\nInput a character: ");
    scanf("%c",&c);
    fun(s,c);
    printf("\nThe result is: %s\n",s);
}


共 18 分 

第42题

在主函数中从键盘输入若干个数放入数组中,用0结束输入并放在最后一个元素中。给定程序MODI1.C中函数fun的功能是:计算数组元素中值为正数的平均值(不包括0)。

例如:数组中元素中的值依次为:39,-47,21,2,-8,15,0,则程序的运行结果为:19.250000。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动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
26
27
28
#include<stdio.h>
double fun ( int x[])
{
    ____1____
    int c=0, i=0;
    while (x[i] != 0)
    {
        if (x[i] > 0)
        {
            sum += x[i]; c++;
        }
        i++;
    }
    ____2____
    return sum;
}
main()
{
    int x[1000];
    int i=0;
    printf"\nPlease enter some data (end with 0): " );
    do
    {
        scanf("%d", &x[i]);
    }
    while (x[i++] != 0);
    printf("%f\n", fun ( x ));
}
共 18 分 

第43题

编写函数fun,函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。

1 1 1

S=1 + ── + ─── + … + ──────

1+2 1+2+3 1+2+3+…+n

例如:若n的值为11时,函数的值为:1.833333

注意:部分源程序在文件PROG1.C中。

请勿改动主函数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
#include<stdio.h>
float fun(int n)
{
    ____1____
    ____2____
    for(____3____)
    {
        ____4____
        for(____5____)
        t+=j;
        ____6____
    }
    return s;
}
main()
{
    int n;
    float s;
    printf("\nPlease enter N:");
    scanf("%d", &n);
    s = fun(n);
    printf("the result is: %f\n", s);
    NONO();
}
共 24 分 

试卷信息