-
浙江大学
2006-2007
学年冬季学期
p>
《程序设计基础及实验》课程期末考试试卷(
A
)
开课学院:计算机学院
,
考试形式:闭卷
考试时间:
2007
年
1
月
24
日
,
所需时间:
120
分钟,任课教师
考生姓名:
学号:
专业:
(
注意:答题内容必须写在答题卷上,写在本试题卷上无效
)
Section 1: Single
Choice
(
2 mark for each item,
total 20 marks
)
1.
According to the
declaration: int x=23; the value of expression
(x++*1/3) is
______.
A
.
7
B
.
8
C
.
15
D
.
16
2.
According to the
declaration: int a=12; the value of expression
a+=a- =a*=a is ______.
A
.
-120
B
.
144
C
.
0
D
.
-132
3.
According to the
declaration: int a=10, b=20; the value of
expression !a
A
.
1
B
.
0
C
.
10
D
.
20
4.
According to the
declaration: int a; the value of expression
(a&3)==(a%4) is _____.
A
.
0
B
.
1
C
.
uncertain
D
.
expression
error
5.
The following code
fragment prints out _____.
for(a=1,i=-1;-1<=i<1;i++)
{ a++;
printf(“%2d”,a);
}
printf(“%2d”,i);
A
.
2
B
.
-1
C
.
0
D
.
3
6.
The following code fragment prints out
_____.
char
c[]=“I
tr0will
n”;
printf(“%d”,strlen(c));
A
.
4
B
.
15
C
.
16
D
.
11
7.
The following code
fragment prints out _____.
int a=2,b=9;
do{
b-=a; a++; }while(b--<0);
p
rintf(“a=%d,b=%d
n”,a,b);
A
.
a=1,b=-1
B
.
a=2,b=8
C
.
a=3,b=6
D
.
a=4,b=9
8.
The
following
code
fragment
outputs
the
string
str.
The
loop
condition
str[i]!=?
0?
can
be
replaced
by _______.
char str[80]=”hello,
world”;
f
or (i =
0; str[i] != ?
0?;
i++)
putchar(str[i]);
《
C
Programming
》
TEST PAPER, Jan
24, 2007
1 / 10
A
.
str[i]
B
.
i < 80
C
.
!(str[i] =
?
0?)
D
.
i <= 80
9.
With
regard
to
the
array
definition
“int
a[4];
“
,
which
expression
in
the
follows
is
wrong
_______?
A
.
*a
B
.
a[0]
C
.
a
D
.
a++
10.
The following statements
have defined different arrays. Which statement is
wrong _______?
A
.
int a[1][3];
B
.
int
x[2][2]={1,2,3,4};
C
.
int
x[2][]={1,2,4,6};
D
.
int
m[][3]={1,2,3,4,5,6};
Section 2: Fill in the
blanks
(
2 mark for each item,
total 30 marks
)
1.
2.
3.
4.
The value of expression
!!2007 is ___
1
__.
The value of expression 10>5>1 is
__
0
___.
The value
of expression
sizeof(“%%hel
lo
nworld
n”)
is___
15
__.
The following code fragment prints out
__
020
___.
printf(
5.
Assume
that a=0
,
b=3
,
c=0
,
d=26. After
running the following code fragment, the value of
d
is __
26
___.
if(!b) d=d-10;
else if(a)
if(!c) x=15;
else x=25;
6.
The
following code fragment prints out
__
*2*#*3*#
___.
char x='0',y='1';
switch(!x)
{
case 0: printf(
case 1:
switch(y) {
case '0':
printf(
case '1':
printf(
}
default: printf(
}
7.
To execute the command:
prog at my home
, the value
of *(*(argv+2)+1) is
___
y
___.
8.
The following program prints out
__
3#2#
___.
#include
void f(int *x,int *y)
{
int *p;
p=x; x=y; y=p;
}
void main()
《
C
Programming
》
TEST PAPER, Jan
24, 2007
2 / 10
{
int x=3, y=2;
f(&y, &x);
printf(
}
9.
The following program prints out
__
5#0#
___.
#
include
int f(int m)
{
static int k=0;
int s=0;
for(; k<=m; k++) s++;
return s;
}
void
main( )
{
int s=1;
s=f(4);
printf(
}
10.
The following program prints out ___
-1#-1#-2#
__.
#include
int
fun(int x)
{
int t;
if(x<=0)
t=x;
else
t=fun(x-1)+fun(x-2);
return t;
}
void
main()
{
int i;
for(i=1;i<=3;i++)
printf(
}
11.
The following program prints out
__
298
___.
#include
void
main( )
《
C
Programming
》
TEST PAPER, Jan
24, 2007
3 / 10
{
int i=0, n;
char s[10]=
n=0;
for(i=0; s[i]!='0'; i++)
if(s[i]<='9'&&s[i]>='0')
n=n*10+(s[i]-'0');
else
break;
printf(
}
12.
The following code fragment prints out
__
12
___.
int a[]={1,2,3,4,5,6,7}, *p, s;
for(s=0, p=a+1; p<=a+6; p=p+2)
s+=
*p;
printf(“%d”, s);
13.
Use
typedef
to define a pointer
type that points to a function returning float
type _____.
typedef float *P();
14.
For the following array
a, the value of *(a[1]+1) is
__
4
___.
int a[3][2]={1,2,3,4,5,6};
15.
For the following
definition, the value of
(s[0].b)/(++p)->a
is __
0
___.
struct {
int a;
int b;
} s[2]={2,4,6,8},
*p=s;
Section
3: Read each of the following programs and answer
questions (
5
marks for each
item, total marks: 30)
1
.
When input
:
How Are
You?
, the output of the
following program
is__
Hsa
___.
#include
void
main()
{
char s[80];
int i=0;
scanf(
while(s[i]!='0') {
if(s[i]>='a'&& s[i]<='v') s[i] += 4;
else if(s[i]>='w'&& s[i]<='z') s[i] -=
22;
i++;
}
《
C
Programming
》
TEST PAPER, Jan
24, 2007
4 / 10
-
-
-
-
-
-
-
-
-
上一篇:常见同义替换
下一篇:2019年上半年CATTI三级笔译真题(英译汉)