Académique Documents
Professionnel Documents
Culture Documents
DISA.US
70
Proceso 1
Proceso 2
Estructuras de control
SI NO
Condicin?
NO
Condicin?
SI
Opcin 1 Opcin 2 SI NO
Condicin?
Inicio
Leer a
Leer a, b
Leer b
r a+b
Escribir r
Fin
Estructura secuencial: Ejemplo 2
DISA.US
Leer x
Leer y
r (x y) / 2
Escribir r
Inicio
SI NO
x>=0?
rx r x
Fin
Informtica. GITI. Tema 3.
DISA.US
74
Estructura condicional: Ejemplo 2
Inicio
Leer x
SI
x>0 y
NO
x<=10?
q 1 q 0
Escribir q
i 1
Leer x
Escribir x
i i 1
SI
i<=3?
NO
Estructura iterativa salida encola: Leer tres
nmeros reales y escribirlos
Informtica. GITI. Tema 3.
DISA.US
77
Inicio
i 1
Leer x
Escribir x
Cuerpo del
bucle
SI NO
Condicin?
SI
i<=3?
NO
Condicin de
salida o parada
Fin
N
Estructura iterativa salida en cabeza: Leer
tres nmeros reales y escribirlos
Inicio
i 1
NO
i<=3?
Condicin de
salida o parada Condicin?
SI
SI
Leer x
Escribir x
Cuerpo del
bucle
i i 1
Fin
Informtica. GITI. Tema 3. 78
DISA.US
DISA.US
Inicio
i 1
NO
Condicin?
Leer x
SI
NO
i<=3?
SI
Escribir x
i i 1
SI NO
Condicin?
Fin
Informtica. GI
N
TI
o
. T
s
e
e
ma
us
3
a
.
Inicio
Leer x, y
SI NO
x>0?
SI
NO
y>0?
SI NO
y>0?
r 1 r 4 r 2 r 3
Escribir r
Informtica
F
.
in
GITI. Tema 3. 82
Estructuras decontrol anidadas
Informtica. GITI. Tema 3.
DISA.US
83
Inicio
Leer x, y
SI NO
x>0?
SI
NO
y>0?
SI NO
y>0?
r 1 r 4 r 2 r 3
Escribir r
Fin
Informtica. GITI. Tema 3.
DISA.US
85
7. Traza o tabla de ejecucin
El nmero de sentencias/condiciones
evaluadas por un algoritmo es variables y
desconocido a priori
La dimensin de la traza depende de las
entradas
Al evaluar una condicin, es recomendable
marcar si la condicin era verdadera o falsa
Informtica. GITI. Tema 3.
DISA.US
87
Instruccin a b r
Inicio - - -
Leer a 5 - -
Leer b 5 3 -
r<-a+b 5 3 8
Escribir r 5 3 8
Fin 5 3 8
Problema I: Leer dos nmeros reales y escribir la suma.
Inicio
Leer a
Leer b
r a+b
Escribir r
Fin
Informtica. GITI. Tema 3.
DISA.US
88
Instruccin x r
Inicio - -
Leer x 10 -
x>=0? 10 10
Fin 10 10
Instruccin x r
Inicio - -
Leer x -20 -
x>=0? -20 20
Fin -20 20
Problema II: Hallar el valor absoluto de un
nmero x
Inicio
Leer x
SI
SI NO
x>=0?
r x
r x
Fin
NO
Problema III: Leer tres nmeros reales y
escribirlos
Instruccin i x
Inicio - -
i<-0 1 -
1. i<=3? 1 -
Leer x 1 3.5
Escribir x 1 3.5
i<-i+1 2 3.5
2. i<=3? 2 7.9
Leer x 2 7.9
Escribir x 2 7.9
Inicio
i 1
NO
i<=3?
SI
SI
Leer x
Escribir x
SI
i i 1
Fin
89
Problema III: Leer tres nmeros reales y
escribirlos
DISA.US
Instruccin i x
i<-i+1 3 7.9
3. i<=3? 3 7.9
Leer x 3 2.1
Escribir x 3 2.1
i<-i+1 4 2.1
4. i<=3? 4 2.1
Fin 4 2.1
Inicio
i 1
SI
NO
i<=3?
SI
Leer x
Escribir x
NO
i i 1
Inicio
Leer x
SI NO
x>=0?
r x r x
y r *r *r
Escribir y
Inicio
Leer x
SI
NO
r x
x>=0?
NO
r x
y r *r *r
Escribir y
92
Fin
Problema IV
Instruccin
x r y
Inicio - - -
Leer x 2 - -
x>=0? 2 - -
r <- x 2 2 -
y <- r*r*r 2 2 8
Escribir y 2 2 8
Fin 2 2 8
Inicio
Leer x
SI NO
x>=0?
SI r x r x
y r *r *r
Escribir y
Fin
93