2013年9月全国计算机等级《二级C语言程序设计》上机临考冲刺试卷(1)

时长:120分钟 总分:100分

84浏览 0人已完成答题

题型介绍
题型 单选题 简答题
数量 40 3
一、选择题(每小题1分,共40分)
1.
若有下列定义(设int类型变量占2个字节):
int i=8,j=9;
则下列语句:
printf("i=%%d,j=%%d\n",i,j);
输出的结果是( )。
问题详情




2.
下列描述错误的是( )。
问题详情




3.
以下叙述中正确的是( )。
问题详情




4.
交换两个变量的值,不允许用临时变量,应该使用下列( )位运算符。
问题详情




5.
有如下程序:
main()
{ int a=2,b=-1.c=2;
if(a<0)if(b<0)c=0;
else c++;
printf("%d\n",c);
}
该程序的输出结果是( )。
问题详情




6.
两个或两个以上模块之间联系的紧密程度称为( )。
问题详情




7.
下列程序的输出结果是( )。
#include
main()
{ int a=0,i;
for(i=1;i<5;i++)
{ switch(i)
{ case 0:
case 3:a+=1;
case 1;
case 2:a+=2;
default:a+=3;
}
}
printf("%d",a);
}
问题详情




8.
执行下列程序后,输出的结果是( )。
#include
#define S(X) X*X
void main()
{ int a=9,k=3,m=2;
a/=S(k+m)/S(k+m):
printf("%d",a);
}
问题详情




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




10.
若希望下列的程序运行后输出25,程序空白处的正确选项是( )。
main()
{ int id=50,a[]=(7,4,10,5,8};
for( )
j+=a[i];
printf("%d",j-40);
}
问题详情




11.
当用户要求输入的字符串中含有空格时,应使用的输入函数是( )。
问题详情




12.
已知字符'A'的ASCⅡ代码值是65,字符变量c1的直是'A',c2的值是'D'。执行语句printf("%d,%d",c1,c2-2);后,输出结果是( )。
问题详情




13.
有以下程序:
main()
{ int i,n=0:
for(i=2;i<5;i++)
{ do
{ if(i%3) continue:
n++:
}while(!i);
n++:
}
printf("n=%d\n",n);
}
程序执行后输出结果是( )。
问题详情




14.
下列程序的运行结果为( )。
#include
main()
{ struct date
{int year,month,day;
}today;
printf("%d\n",sizeof(struct date));
}
问题详情




15.
下列关于信息系统的叙述中,错误的是( )。
问题详情




16.
当执行下面的程序时,如果输入ABC,则输出结罘是( )。
#include
#include
main( )
{ char ss[10]="1,2,3,4,5":
gets(ss);strcat(ss,"6789");printf("%s\n",ss);
}
问题详情




17.
软件设计包括软件的结构、数据接口和过程设计,其中软件的过程设计是指( )。
问题详情




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




19.
若已包括头文件且已有定义char sl [18],s2={"ABCDE")和int i,现要将字符串”ABCDE”赋给sl,下列语句错误的是( )。
问题详情




20.
作为信息处理热点技术之一的“多媒体技术”中的媒体,强调的是( )。
问题详情




21.
设int x=7,则~x的值是( )。
问题详情




22.
以下程序的输出结果是( )。
#define M(x,y,z)x*y+z
main( )
{ int a=l,b=2,c=3;
printf("%d\n",m(a+b.b+c,c+a));
}
问题详情




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




24.
有以下程序:
main()
{ union
{ char ch[2];
int d;
}s;
d=0x4321;
printf("%x,%x\n",S.ch[0],S.ch[l]);
}
在16位编译系统上,程序执行后的输出结果是( )
问题详情




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




26.
有以下程序段:
int x=3;
do
{printf("%d",x-=2);)
while(!(--x));
其输出结果是( )。
问题详情




27.
下列叙述中不正确的是( )。
问题详情




28.
运行下列程序时,若输入的数据为“1,2,3”,则输出结果是( )。
main()
{ float a,b,c,t;
scanf("%f,%f,%f",&a,&b,&c);
if(a<B)
{t=a;a=b.b=t;)
if(a<C)
{t=a;a=c;c=t;)
it(b<C)
{t=b;b=C;c—=;)
printf("%f\n%f\n%f\n",a,b,c);
}
问题详情




29.
设x=011050,则x=x&01252的值是( )。
问题详情




30.
定义结构体数组:
struct stu
{ int num;
char nameE20];
}X[5]={1,"LI",2,"ZHAO",3,"WANG",4," ZHANG",5,"LIU");
for(i=1;i<5;i++)
printf("%d%c",x[i].num,x[i].name[2]);
以上程序段的输出结果为( )。
问题详情




31.
设有以下语句:
int a=1,b=2,c;
c=a^(b<<2);
执行后,c的值为( )。
问题详情




32.
有以下程序:
main()
{ int x,i;
for(i=l;i<=50;i++)
{ x=i:
if(x%2=0)
if(x%3=0)
if(X%7=0)
printf(”%d,i)”;
}
}
输出结果是( )。
问题详情




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




34.
以下正确的字符串常量是( )。
问题详情




35.
下列叙述中错误的是( )。
问题详情




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




37.
下列判断正确的是( )。
问题详情




38.
有以下程序:
main()
{ int num[4][4]={1,2,3,4},{5,6,7,8},{9,10,11,
12,},{13,14,15,16}},i,j;
for(i=0;i<4;i++)
{ for(j=0;j<I;J++)PRINTF("%4C",'');
for(j=________;J<4;j++)printf("%4d",num
[i][j]);
printf("\n");}}
若要按以下形式输出数组右上半三角
1 2 3 4
6 7 8
11 12
16
则在程序下划线处应填入的是( )。
问题详情




39.
设有条件表达式:(EXP)?i++;j--,则以下表达式中(EXP)完全等价的是( )。
问题详情




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




二、程序填空题(共18分)
41.
请补充函数proc(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,str指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。例如,当str输入“abcabcabcab”,c=b时,b的输出为“abcabcaca”;如果str的输入为“abcabcabca”,则b的输出为“abcabcabca”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅程函数prOC()的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define M 80
void proc(char str[],char b[],char c)
{
int i=0,j=0;
int n=0:
int m=0:
while(str[i]!='\0')
{
if(str[i]==c)
n++:
i++:
}
【1】 ;
if(n%2)
{
while(str[j]!='\0 ')
{
b[j]=str[j];
j++;
}
b[j]='\0';
}
else
{
while(str[i]!='\0 ')
{
b[j++]=str[i];
if(str[i]==c)
m++:
if((m>n/2)&&(str[i]==c))
【2】 ;
i++:
}
【3】 ;
}
}
void main()
{
char str[M],b[M];
char C;
system("CLS");
printf("Enter the strin9:\n");
gets(str);
printf("Enter the character of the
string deleted:"):
scanf("%C",&c);
proc(str,b,c);
printf("The new string is:%s\n",b);
}
问题详情
三、程序改错题(共24分)
42.
下列给定程序中,函数proc()的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码升序排序后输出。
例如,输入opdye,则应输出deopy。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include
#include
#include
#include
//****found****
int proc(char str[])
{
char c;
unsigned i,j;
for(i=0;i<STRLEN(STR)-1;I++)
for(j=i+1;j<STRLEN(STR);J++)
if(str[i]>str[j])
{
c=str[j]:
//****found****
str[j]=str[i++];
str[i]=c;
}
}
void main()
{
char str[81];
system("CLS");
printf("\nPlease enter a character
string:");
gets(str);
printf("\n\nBefore sorting:\n%s",str);
proc(str);
printf("\nAfter sorting decendingly:\n
%s",str);
}
问题详情
四、程序设计题(共18分)
43.
请编写一个函数proc(),它的功能是:求出1~m(含m) 能被7或11整除的所有整数放在数组a中,通过n返回这些数的个数。
例如,若传给m的值为70,则程序输出:
7 11 14 21 22 28 33 35 42 44 49 55 56 63 66 70
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的花括号中填人所编写的若干语句。
试题程序:
#include
#include
#include
#define N 100
void proc(int m,int*a,int*n)
{
}
void main()
{
int arr[N],n,k;
system("CLS");
proc(70,arr,&n);
for(k=0;k<N;K++)
if((k+1)%20==0)//每行输出20个数
{ printf("%4d",arr[k]);
printf("\n");
}
else
printf("%4d",arr[k]);
printf("\n");
}
问题详情