Prof. Tak Auyeung
You, as an individual, are expected to do your own work. This means you cannot seek, receive or otherwise acquire any assistance except clarifications from the professor during an examination. Any communication involving the contents of the subject matter or the examination is considered cheating. Do not initiate or accept such communication, or the result of your examination is automatically voided.
New rules, read this! As of 2003.09.22, I no longer deduct points for wrong answers. Each correct answer is worth one point, each wrong answer is worth zero point, and each unanswered question is also worth zero point. This means you should guess and leave no question unanswered.
As a result, I also need to adjust the letter grade assignment break points. For your individual examinuation, ``A'' means at least 94%, ``B'' means at least 74%, ``C'' means at least 54%, ``D'' means at least 34% and ``F'' means below 34%. The break points for the final grade are now 26.83%, 48.5%, 70.17% and 91.83% as minimums for ``D'', ``C'', ``B'' and ``A'', respectively.
Please note that this change does not affect your letter grade at all, it is just a number game to make some people feel better about guessing.
Make sure you write down you name on the upper right corner first, otherwise I cannot give points to anonymous students!
The baseline is 10, there are 12 questions.
____ in the following code
so there is no syntax error?
var
knives :
____
i : integer;
x : real
end;
array
record
integer
boolean
real
procedure p1(var x : integer; var y : integer);
begin
y := x + y div 2;
x := y + 2 * x
end;
procedure p2(var x : integer; var y : integer);
begin
y := x + y div 2;
x := y + 2 * x;
p1(x,y)
end;
var
x, y : integer;
begin
x := 10;
y := 20;
p2(x,y);
writeln(x,' ',y)
end.
150 30
150 50
40 10
40 20
40 30
var
a : array [0..2] of integer;
i : integer;
begin
i := 0;
while (i < 3) do
begin
a[i] := (1 + i * 2) mod 3;
i := i + 1
end;
i := 0;
while (i < 3) do
begin
write(a[a[i]],' ');
i := i + 1
end;
writeln
end.
0 1 2
2 1 0
0 2 1
2 0 1
1 2 0
function f(var a : array of integer; n : integer) : integer;
var i : integer;
x : integer;
begin
i := 0;
x := 0;
while i < n do
begin
x := x + a[i];
i := i + 1
end;
f := x
end;
i := 0;
while i < 3 do
begin
if a[i] < a[5-i] then
begin
x := a[i];
a[i] := a[5-i];
a[5-i] := x
end;
i := i + 1
end;
type
c =
record
r : real;
i : real
end;
procedure ca(var s : c; x : c);
var
t : c;
begin
t.r := s.r + x.r;
t.i := s.i + x.i;
s := t
end;
var
x, y : c;
begin
x.r := -2.0;
x.i := 2.0;
y.r := 7.0;
y.i := -5.0;
ca(y, x);
writeln(y.r,',',y.i)
end.
We know that size is some integer larger than two.
lo := 0;
hi := size-1;
repeat
me := (hi + lo) div 2;
if mystery > a[me] then
lo := me + 1
else if mystery <= a[me] then
hi := me
until (lo > hi) or (mystery = a[me]);
function f(var a : array of integer; n : integer) : boolean;
var
i : integer;
b : boolean;
begin
i := 0;
b := true;
repeat
b := (a[i] < a[i+1]);
i := i + 1
until (not b) or (i >= n-1);
f := b
end;