Programowanie strukturalne (2)


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;0x01 graphic

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:

0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic

0x08 graphic

0x08 graphic

0x08 graphic
0x08 graphic
+ +

0x08 graphic

_ _

0x08 graphic

0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
Odp: Zad 4

_

+

+ _

_ +

ZAD 5

Ustrukturalnić następujący schemat blokowy:

0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic

+

0x08 graphic

0x08 graphic

_

+

_

Odp: Zad5

0x08 graphic

0x08 graphic

0x08 graphic

0x08 graphic

0x08 graphic
0x08 graphic

0x08 graphic
0x08 graphic

_

0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
0x08 graphic
_

+

+

_

_

+

0x08 graphic

0x08 graphic
0x08 graphic
0x01 graphic

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



Wyszukiwarka

Podobne podstrony:
Programowanie strukturalne w C
plikus pl Programowanie strukturalne, Wyklad z C
Programowanie strukturalne i obiektowe
Programowanie strukturalne i obiektowe Podręcznik do nauki zawodu technik informatyk
dokumentacja, Zasady Programowania Strukturalnego (ZAP)
Zmienne tablicowe, INFORMATYKA, INFORMATYKA sem. III, 2.Prograowanie strukturalne i obiektowe
Programowanie strukturalne i obiektowe Podrecznik do nauki zawodu technik informatyk prstko
BLOKI, Programowanie strukturalne i obiektowe, C ++, Ćwiczenia C++ (skan)
Programowanie opracowanie, Informatyka, Informatyka semestr II, 3.Programowanie strukturalne i obiek
ALGORYTMY-PREZENTACJA, SZKOLNE PLIKI-mega zbiory (od podstawówki do magisterki), Programowanie struk
Programowanie strukturalne i obiektowe Podrecznik do nauki zawodu technik informatyk prstko 2
Systemy obliczania w praktyce, INFORMATYKA, INFORMATYKA sem. III, 2.Prograowanie strukturalne i obie
Typy danych i ich klasyfikacja, INFORMATYKA, Programowanie strukturalne i obiektowe, Semestr 1
STRING - Procedury i funkcje, Szkoła, Klasa 1, Programowanie struktularne i obiektowe

więcej podobnych podstron