Ustrukturalnić następujący fragment programu :
if a=b then goto et4;
a: = a+1;
if c=d then goto et7 else goto et8;
et 4: b : =b+1;
c : =c+1;
d : =d+1;
et8: e: =e+1;
goto et10
et7 : if x=y then goto et11;
et10 : f : =f+1
et11 : g : =g+1
rozwiązanie:
if a=b then
begin
b: =b+1;
c: =c+1;
d: =d+1;
e: =e+1;
f: =f+1;
end
else
begin
a: =a+1;
if c=d then
begin
if x<>y then f: =f+1
end
else
begin
e: =e+1
f ; =f+1
end
end;
g: =g+1
Ustrukturalnić następujący fragment programu :
for i: =1 to n do
if A[i]=x then goto jest;
i: =n ;
A[i]: =x;
B[i]: =0;
jest : B[i]: =B[i]+1;
Rozwoązanie:
{wprowadzamy zmienną P typu boolean}
i: =1;
P: =true;
while P do
if i>n then
begin
i: =n;
A[i]: =x;
P: =false
end
else
if A[i]=x then
P: =false
else
i: =i+1;
B[i]: =B[i]+1;
Ustrukturalnić następujący fragment programu :
et1 : if a =b then goto et2 else goto et3;
et2 : if c =d then goto et4 else goto et5;
et3 : if e =f then goto et5 else goto et6;
et5 : if g =h then goto et7 else goto et8;
et4: x: =x+1;
et7: y: =y+1;
goto et9;
et6: z: =z+1
et8: t: =t+1
et9: v: =v+1
rozwiązanie:
if a=b then
if c=d then
begin
x: =x+1;
y: =y+1;
end
else if g=h then
y: =y+1
else
t: =t+1
else if e=f then
if g=h then
y: =y+1
else
t: =t+1
else
begin
z: =z+1;
t: =t+1
end;
v: =v+1
ZAD 4
Ustrukturalnić następujący schemat blokowy:
+ +
_ _
Odp: Zad 4
_
+
+ _
_ +
ZAD 5
Ustrukturalnić następujący schemat blokowy:
+
_
+
_
Odp: Zad5
_
_
+
+
_
_
+
START
STOP
1
2
3
4
5
6
7
START
STOP
P: =true
P: = false
P
1
2
3
4
2
6
7
5
STRT
A
1
2
B
C
STOP
START
STOP
P:=true
P
A
1
2
C
P:=falses
B
1
2
B
C
A
STOP
START
D
E
3
A
STOP
D
C
B
2
START
1