Buscar este blog

miércoles, 28 de marzo de 2012

28 de marzo

ANIDAMIENTO DE INSTRUCCIONES

Ejemplo:
i:entero
j:entero
PARA i=0 HASTA 5
Inicio
            PARA j=0 HASTA 3
            Inicio
                      Escribir ("Hola")
            Fin
Fin

-Calcular el mayor de tres numeros:

a:entero
b:entero
c:entero
Leer(a)
Leer(b)
Leer(c)
SI (a>b) AND (a>c)
Inicio
       Escribir ("El mayor es a")
Fin
SINO
Inicio
        SI (b>a) AND (b>c)
        Inicio
                Escribir ("El mayor es b")
         Fin
         SINO
         Inicio
                 Escribir ("El mayor es c")
         Fin
Fin

-Dada una fecha por teclado (dia,mes y año de tipo entero) que salga por pantalla en el formato: 28 de Marzo de 2012.

d:entero
m:entero
a:entero
Escribir ("Dime el dia (1-31)")
Leer (d)
Escribir ("Dime el numero de mes (1-12)")
Leer (m)
Escribir("Dime el año")
Leer (a)
CASO (mes)
Inicio
        Valor 1:
         Inicio
                     Escribir( "La fecha es", d, "enero", a)
         Fin
         .
         .
         .
         Valor 12:
         Inicio
                     Escribir( "La fecha es", d, "diciembre", a)
         Fin
Fin



ESTRUCTURA GENERAL DE UN PROGRAMA

PROGRAMA nombre
INICIO
VAR
         a:entero      
         b:real           DECLARACIONES
         c:cadena

.
.        IMPLEMENTACION (Instrucciones)                  
.
FIN

-Ejercicio divisores con la estructura

PROGRAMA divisores
INICIO
VAR
            a:entero
            i:entero
ESCRIBE (“Introduce un numero: “)
LEER (a)
PARA i=1 HASTA a
INICIO
            SI (a MOD i =0)
            INICIO
                        Escribe(i, ”es divisor de”, a)
            FIN
FIN
FIN



No hay comentarios:

Publicar un comentario