Задания.
Раздаточный материал
1. Чему будут равны а, b, S, K после выполнения следующих
операторов:
а) S:=0; K:=10; a:=5;
if a>=0 then S:=S+10 else
begin S:=S-10; K:=K+S; end;
b) S:=0; K:=10; a:=3;
if a<0 then S:=S+10 else begin S:=S+10; K:=K-S; end;
c) S:=40; K:=0; a:=15;
if a=15 then begin S:=S+10; K:=K+S-a; end else S:=S-10;
d) S:=0; K:=0; a:=5;
if a>=10 then S:=S+10 else S:=S-10; K:=K+S;
e) S:=0; K:=0; a:=1; b:=1;
if (a>=0) and (b<1) then S:=S+10 else begin S:=S-10;
K:=K+S-3; end;
f) S:=0; K:=0; a:=1; b:=1;
if (a>=0) and (b>=1) then S:=K+10 else begin K:=S-10;
S:=K+S-3; end;
g) S:=2; K:=0; a:=1; b:=1;
if (a>=0) or (b<1) then begin S:=S+1; a:=S+K; end
else begin S:=S-1; K:=K-S; end;
k) S:=0; K:=0; a:=1; b:=1;
if a>=0 then if b>=1 then S:=S+11 else S:=a+b;
m) S:=4; K:=2; a:=0; b:=0;
if a>=0 then if b<-1 then S:=K else begin S:=S-1;
K:=S; end else S:=100;
n) S:=10; K:=7; a:=0; b:=1;
if (a>=0) and (b<1) then S:=S+10 else begin S:=S-10;
K:=K+S-3; end;
l) S:=0; K:=0; a:=1; b:=1;
if a=b then S:=S+1 else if a>b then S:=S-a else K:=K-b;
o) S:=0; K:=0; a:=1; b:=1;
if a=b then S:=S+a-b;
if a>=b then S:=S-a/b else K:=K-b/a;
2.Значения поменять a, b, c местами так, чтобы оказалось: a>=b>=c.
3. Значения поменять a, b, c местами так, чтобы оказалось: a<=b<=c.
4. По номеру у (у>0)
некоторого года определить с- номер столетия (учесть, что, к примеру, началом XX
столетия был 1901, а не 1900 год).
Ответы (решения)
a) a=5; s=10; k=10;
b) a=3; s=10; k=0;
c) a=15; s=50; k=35;
d) a=5; s=-10; k=0;
e) a=b=1; s=-10; k=-13;
f) a=b=1; s=10; k=0;
g) a=3; b=1; s=3; k=0;
k) a=b=1; s=11; k=0;
m) a=b=0; s=k=3;
n) a=0; b:=1; s=0; k=4;
l) a=b=1; s=1; k=0;
o) a=b=1; s=-1; k=0;
2. if a<b then begin r:=a; a:=b; b:=r; end; (a>=b)
if a<c then begin r:=a; a:=c; c:=r; end; (a>=c)
if b<c then begin r:=b; b:=c; c:=r; end; (b>=c)
3. if a>b then begin r:=a; a:=b; b:=r; end; (a<=b)
if a>c then begin r:=a; a:=c; c:=r; end; (a<=c)
if b>c then begin r:=b; b:=c; c:=r; end; (b<=c)
4. c:=y div 100;
if y mod 100<>0 then c:=c+1; |