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

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


第1题

结构化程序的三种基本控制结构是(   )。

共 1 分 

第2题

软件按功能可以分为应用软件、系统软件和支撑软件(或工具软件)。下面属于应用软件的是(  )。

共 1 分 

第3题

通常软件测试实施的步骤是(  )。

共 1 分 

第4题

下面描述中错误的是(  )。

共 1 分 

第5题

结构化程序所要求的基本结构不包括(  )。

共 1 分 

第6题

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

共 1 分 

第7题

下列关于栈叙述正确的是(  )。

共 1 分 

第8题

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

共 1 分 

第9题

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

共 1 分 

第10题

若变量均已正确定义并赋值,以下合法的C语言赋值语句是 (  )。

共 1 分 

第11题

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

共 1 分 

第12题

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

共 1 分 

第13题

设有定义:

1
int a;float b;

执行scanf("%2d%f",&a,&b);语句时,若从键盘输入876 543.0,则a和b的值分别是( )。

共 1 分 

第14题

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

共 1 分 

第15题

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

共 1 分 

第16题

以下能正确表述算式 sin(2πr+30°)的C语言表达式是( )。

共 1 分 

第17题

设有定义:

1
char s[81];int i=0;

以下不能将一行(不超过80个字 符)带有空格的字符串正确读入的语句或语句组是( )。

共 1 分 

第18题

有以下程序

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h> 
main() 
char c1,c2,c3,c4,c5,c6; 
scanf("%c%c%c%c", &c1,&c2,&c3,&c4); 
c5=getchar(); 
c6=getchar(); 
putchar(c1); 
putchar(c2); 
printf("%c%c\n",c5,c6); 
}

程序运行后,若从键盘输入(从第1列开始) 123<回车> 45678<回车> 则输出结果是( )。

共 1 分 

第19题

有以下程序

1
2
3
4
5
6
7
8
9
10
#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 分 

第20题

对于if(表达式)语句,以下叙述正确的是(   )。

共 1 分 

第21题

以下程序段中的变量已正确定义

1
2
3
for( i=0; i<4; i++,i++ )
 for( k=1; k<3; k++ );
printf("*" );

该程序段的输出结果是( )。

共 1 分 

第22题

有以下程序

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

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

共 1 分 

第23题

有以下程序:

1
2
3
4
5
6
7
#include <stdio.h> 
main( ) { 
int i, array[6] = {1, 5, 0, 4}; 
for (i=0; i<5; i++) 
printf("%d,", array[i] & 4); 
printf("\n"); 
}

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

共 1 分 

第24题

若有定义语句:

1
int m[][3]={1,2,3,4,5,6,7};

则与该语句等价的是 ( )。

共 1 分 

第25题

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

共 1 分 

第26题

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

共 1 分 

第27题

若有定义:char s[30] = {0};运行时输入:This is a string.<回车>则以下不能正确读入整个字符串:This is a string.到字符数组 s 中的语句组是( )。

共 1 分 

第28题

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

共 1 分 

第29题

有以下程序

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

程序的运行结果是( )。

共 1 分 

第30题

有以下程序

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

程序的输出结果是( )。

共 1 分 

第31题

设有定义:

1
 int x=0, *p;

紧接着的赋值语句正确的是( )。

共 1 分 

第32题

有以下程序

1
2
3
4
5
6
7
#include <stdio.h> 
int add(int a,int b) { 
return (a+b); 
main() { 
int k, (*f)(),a=5,b=10; 
f=add; … }

则以下函数调用语句错误的是( )。

共 1 分 

第33题

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

共 1 分 

第34题

设已有定义:float x;则以下对指针变量p进行定义且赋初值的语句中正确的是( )。

共 1 分 

第35题

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

共 1 分 

第36题

有以下程序:

1
2
3
4
5
6
7
 #include<stdio.h> 
 #define PT 3.5; 
 #define S(x) PT*x*x; 
 main() { 
 int a=1,b=2;
 printf("%4.1f\n",S(a+b)); 
 }

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

共 1 分 

第37题

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

共 1 分 

第38题

有以下程序

1
2
3
4
5
6
7
8
#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 分 

第39题

有以下程序

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

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

共 1 分 

第40题

有以下程序

1
2
3
4
5
#include <stdio.h>
main()
{
printf("%d\n", NULL);
}

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

共 1 分 

第41题

给定程序中,函数fun的功能是:计算下式前n项的和作为函数的返 回值 

公式

例如,当形参n的值为10时,函数返回:9.612558。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得 出正确的结果。注意:源程序存放在考生文件夹下的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
24
25
26
27
28
/**********code.c**********/
 #include <stdio.h>
double fun(int n)
 {
 int i;
double s,t;
 /**********found**********/
 s=①______;
 /**********found**********/
 for(i=1; i<=②______; i++)
 {
 t=2.0*i;
 /**********found**********/
 s=s+(2.0*i-1)*(2.0*i+1)/③______;
 }
 return s;
 }
 main()
 {
 int n=-1;
 while(n<0)
 {
 printf("Please input(n>0): ");
 scanf("%d",&n); 
}
 printf("\nThe result is: %f\n",fun(n));
 }
 /**********-code.c**********/
共 20 分 

第42题

给定程序MODI1.C中函数fun的功能是:统计substr所指子字符串在 str所指字符串中出现的次数。 例如,若字符串为aaas lkaaas,子字符串为as,则应输出2。 请改正程序中的错误,使它能计算出正确的结果。 注意:不要改动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
/**********code.c**********/
 #include <stdio.h>
int fun (char *str,char *substr)
 {
 int i,j,k,num=0;
 /**********found**********/
 for(i = 0, str[i], i++)
 for(j=i,k=0;substr[k]==str[j];k++,j++)
 /**********found**********/
 If(substr[k+1]=='\0')
 {
 num++;
 break;
 }
 return num;
 }
 void main()
 {
 char str[80],substr[80];
 printf("Input a string:") ;
 gets(str);
 printf("Input a substring:") ;
 gets(substr);
 printf("%d\n",fun(str,substr));
 }
 /**********-code.c**********/
共 40 分 

第43题

请编写一个函数fun,他的功能是:根据以下公式求 π的值(要求满 足精度0.0005,即某项小于0.0005时停止迭代):

公式

 程序运行后,如果输入精度0.0005,则程序输出为3.14…。 注意部分源程序存在文件PROG1.C立件中。 请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花 括号中填入你编写的若干语句。

1
2
3
4
5
6
7
8
9
10
11
12
13
/**********code.c**********/
#include <stdio.h>
#include <math.h>
double fun(double eps)
 {
 }
 void main()
 {
 double x;
 printf("Input eps:") ;
 scanf("%lf",&x);
printf("\neps = %lf,PI=%lf\n", x, fun(x));
 }

参考答案:

1
2
3
4
5
6
7
8
9
10
11
12
double fun(double eps)
 {
 double s=1.0,s1=1.0;
 int n=1;
 while(s1>=eps)/*当某项大于精度要求时,继续求下一项*/
 {
 s1=s1*n/(2*n+1);/*求多项式的每一项*/
 s=s+s1;/*求和*/
 n++;
 }
 return 2*s;
 }
共 0 分