2014年全国计算机等级《二级C语言程序设计》考前押密试题(3)

时长:120分钟 总分:100分

104浏览 0人已完成答题

题型介绍
题型 单选题 简答题
数量 40 3
一、选择题(每小题1分,共40分)
1.
若已定义:int a口一(0,1,2,3,4,5,6,7,8,9),*p=a,i;其中0≤i≤9,则对a数组元素的引用不正确的是(  )。
问题详情




2.
视图设计一般有3种设计次序,下列不属于视图设计次序的是( )。
问题详情




3.
下列运算符中优先级最高的算符是(  )。
问题详情




4.
有以下程序:
int fun(int n)
{ if(n==1)retHrn 1;
else return(n+fun(n—1)):
)
main()
{ int x;
scanf(”%d”,&x);x=fun(x);printf(”%d\n”,
x):
}
执行程序时,给变量X输入10,程序的输出结果是(  )。
问题详情




5.
以下能正确定义一维数组的选项是(  )。
问题详情




6.
下列程序执行后的输出结果是( )。
void func(int*a,int b[])
{b[o]=*a+b;)
main()
{ int a,b[5];
a=0;b[0]=3;
rune(&a.b);printf(”%d\n”,b[o]);
}
问题详情




7.
下列4个关于C语言的结论中错误的是(  )。
问题详情




8.
以三级模式为框架形成的3种数据库中,真实存在于计算机外存的数据库是( )。
问题详情




9.
与“y一(x>O?1:x<0?—1:0)”;的功能相同的if语句是(  )。
问题详情




10.
数据库系统的核心是(  )。
问题详情




11.
若有以下的定义:“int t[a][2];”,能正确表示t数组元素地址的表达式的是(  )。
问题详情




12.
有以下程序
#include
struct tt
{int x;struct tt*y;)*P;
struct tt a[4]={20,a+1,15,a+2,30,a+3,17,a);
main()
{ int i;
P—a: .
for(i=1;i<=2;i++)(printf(”%d,”,p->x);P
=P->y:}
)
程序的运行结果是(  )。
问题详情




13.
以下选项中正确的实型常量是(  )。
问题详情




14.
有下列函数定义:
int fun(double a,double b)
{return a*b;)
若下列选项中所用变量都已经正确定义并赋值,错误的函数调用是( )。
问题详情




15.
有以下程序:
main()
{int a=0,b=0;
a=10; /*给a赋值
b=20; 给b赋值 */
printf(”a+b=%d\n”,a+b);//输出计算机结果
)
程序运行后的输出结果是(  )。
问题详情




16.
以下程序的输出结果是(  )。
main()
{int i,a[4][4]={{1,3,5},{2,4,6},{3,5,7}};
printf(”%d%d%d%d\n”,a[0][3],a[1][2],
a[2][1],a[3][0];
}
问题详情




17.
下述程序的运行结果是( )。
# include
#include
main()
{ char*s1=”abDui¨;
char*s2=”ABdUG”:
int t;
t=strcmp(s1,s2);
printf(”%d”,t);
}
问题详情




18.
语句“printf(”a\bre”\'hi\’y\\\bou\n”);”的输出结果是( )。
问题详情




19.
下面程序段的输出结果是(  )。
int i=32770:printf(”%d\n”,i);
问题详情




20.
下列运算符中优先级最低的算符是(  )。
问题详情




21.
有以下程序:
#include
main()
{ char c1='A',c2='Y';
printf(”%d,%d\n”,c1,c2);
)
程序的输出结果是( )。
问题详情




22.
设有定义:“int a;float b;”,执行“scanf(”%2d%f”,&a,&b);”语句时,若从键盘输入876543.o<回车>,a和b的值分别是( )。
问题详情




23.
设有二元关系R和三元关系s,下列运算合法的是(  )。
问题详情




24.
有以下程序:
#include
main()
{ int i;
for(i一1;i<一5;i++)
(if(i%2)printf(”*”);
e|se continue;
printf(”#”);
}
printf(”$\n”);
程序的输出结果是(  )。
问题详情




25.
结构化程序设计的3种结构是(  )。
问题详情




26.
下面for语句的循环次数为(  )。
for(x=1,y=0;(Y!=19)&&(x<6);x++);
问题详情




27.
语句:“printf(”%d”,(a=2)&&(b=-2));”的输出结果是(  )。
问题详情




28.
以下程序的输出结果是(  )。
void fun(int*a,int i,int j)
{int t;
if(i<I)
(t=a[i];a[i]=a[j];a[j]=t;
i++;j--;
fun(a,i,j);
)
}
main()
{int x[]={2,6,1.8),i;
fun(x,0,3):
for(i=0;i<4;i++)printf(”%2d”,x[i]);
printf(”\n”);
)
问题详情




29.
常采用的两种存储结构是(  )。
问题详情




30.
有以下程序:
main()
{ int x=102,y=012;
printf(”%2d,%2d\n”,x,y);
}
执行后输出结果是(  )。
问题详情




31.
运行下列程序,若从键盘输入字符“a”,则输出结果是(  )。
char C;
c=getchar();
if(c>='a'&&c<='g')c=c+4;
else if(c>='g'&&c<='z')c=c-21;
else print{(”input error!\n”);
putchar(c):
问题详情




32.
相对于数据库系统,文件系统的主要缺陷有数据关联差、数据不一致性和( )。
问题详情




33.
若有以下定义和语句:“double r=99,*p=&r;*P=r;”,则以下正确的叙述是(  )。
问题详情




34.
有以下程序段:
int k,j,s;
for(k=2;k<6;k++,k++)
{ s=1;
for(j=k;j<6;j++)s+=j;
)
print[(”%d\n”,s);
程序段的输出结果是(  )。
问题详情




35.
设有以下定义
union data
( int dl;f|aat d2;)dem0;
则下面叙述中错误的是(  )。
问题详情




36.
算法分析的目的是(  )。
问题详情




37.
设有如下定义:
int arr[]={6,7,8,9,10};
int*ptr;
ptr=art;
*(ptr2)=2:
printf(”%d,%a\n”,*ptr,*(ptr2));
则下列程序段的输出结果为(  )。
问题详情




38.
设有程序段:
int k=12;
while(k=1)k=k-1:
则下列描述中正确的是(  )。
问题详情




39.
有下列程序:
main()
{int i,s=0,t[]={1,2,3,4,5,6,7,8,9);
for(i=0;i<9;i+=2)s+-*(t+i);
printf(”%d\n”,s);
)
程序执行后的输出结果是(  )。
问题详情




40.
有下列程序:
#include
main()
{ int a=6,b=7,m=1;
switch(a%2)
{ case 0:m++;break;
case 1:m++;
switch(b%2)
{default:m++;
case 0:m++;break;
)
)
printf(”%d\n”,m);
程序的运行结果是(  )。
问题详情




二、程序填空题(共18分)
41.
请补充main()函数,该函数的功能是:输入两个正整数numl和num2,求这两个数的最大公约数和最小公倍数。
例如,若输人的两个正整数为12,4,则它们的最大公约数为4,最小公倍数为12。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
void main()
{
int a,b,numl,num2,t;
system(”CLS”):
printf(”\nlnput tWO numbers:\n”);
scanf(”%d,%d”,&numl,&num2);
if(numl<NUM2)
{
a=num2;
b=numl;
}
else
{
a=num1:
b=num2:
)
while(【1】)
{
t=【2】
a=b;
b=t;
}
printf("greatest common divisor:
%d\n”,a);
printf(”least common multiple:
%d\n”,【3】);
问题详情
三、程序改错题(共24分)
42.
下列给定程序中,函数proe()的功能是:对M名学生的学习成绩,按从高到低的顺序找出前m(m<10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。
请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include%stdlib.h>
#include
#include
#include
#include%malloe.h>
#define M 10
typedef struct ss
{
char num[10];
int s;
}
STU;
STU *proc(STU a[],int m)
{
STU b[-M],*t;
int i,j,k;
//****found****
*t=calloc(m,sizeof(STU));
for(i=0;i
for(k=0;k<M;K++)
{
for(i=j=0;i<M;I++)
if(b[i].s>b[j].s)j=i;
//****found****
t[k].num=b[j].num;
t[k].s=b[j].S;
b[j].s=0;
}
return t:
}
void outresuh(STU a[],FILE *pf)
f
int i;
for(i=0;i<M;I++)
fprintf(pf,”No=%s Mark=%d\n”,
a[i] mum,a[i].s);
fprintf(pf,”\n\n”);
)
void main()
{STU stu[M]={{¨A01”,81},{¨A02”,89},
{¨A03”,66},{”A04”,87),{”A05”,77),
{”A06”,90),{"A07”,79),{”A08”,61),
{”A09”,80},{”A10”,71));
STU+pOrder;
int i,m;
system(”CLS”);
printf(”****THE RESULT****\n”);
outresuh(stu,stdout);
print{(”\nGive the number of the students
who have better score:”);
scanf(”%d”,&m);
while(m>10)
printf(”\nGive the number of the
students who have better score:”);
scanf(”%d”,&m);
}
p()rder=proc(stu,m);
printf(”****THE RESULT****\n”);
printf(”The lop:\n”);
for(i=0:i<M:I++)
printf(”%s%d\n”,pOrder[i].hum,
pOrder[i].s);
free(pOrder);
)
问题详情
四、程序设计题(共18分)
43.
学生的记录由学号和成绩组成,M名学生的数据已在主函数中放入结构体数组stu中,请编写函数proc(),其功能是:按分数的高低排列学生的记录,高分在前。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填入所编写的若干语句。
试题程序:
# include
#define M 16
typedef s truct
{
char num[10];
inl S;
)
STREC;
void proc(STREC a[])
int i,j;
STREC t;
for(i=1;i<M;I++)&NBSP; *用冒泡法按从高到低
排序*/
for(j=0;j<M-1;J++)
if(a[j].s
的记录,高分在前*/
{t=aEP;a[j]=a[j+1];a[j+1]=t;}
}
void main ()
{
STREC,sluEM]={{ ”GA005”,85),{¨GA003”,
76},
{”GA002“,69},{¨GA004”,815}.{¨GA001”,91},
{"GA007”,72},{“GA008”,64),{"GA006”,87},
{¨GA015”,85},i”GAO13”,91},{”GA012”,64},
{"GA014”,91},{”GA011”,66},{¨GA017”,64},
{”GA018”,64},{¨GA016”,72}};
in/i;
proc(stu):
prinlf(”The data afwr sorted:\n”);
for(i=0;i<M:I++)
{
if(i%4==0)
//每行输出4个学生记录
printf(”\n”);
printf(”%sM”,stu[i].num,stu[i].s);
}
printf(”\n”):
}
问题详情