EJERCICIO 2
Desarrollar un algoritmo que convierta un numero de segundos en su
EJERCICIO 3
Desarrollar un algoritmo que encuentre el mximo entre 3 nmeros:
FORMULA mximo entre dos nmeros---> Mximo = ((a+b)+abs (a-b))/2
ANALISIS
DE: Tres nmeros reales
DS: 1 Numero real
Debo saber que: Mximo = ((a+b)+abs (a-b))/2
DISEO
Algoritmo Maximo;
Lxico
a,b,c,max,maximo : R
Inicio
Escribir (Ingrese tres nmeros)
Leer (a,b,c)
max ((a+b)+abs(a-b))/2
maximo ((max + c) + abs (a-b))/2
Escribir (El mximo es, maximo)
Fin
PASCAL
Program Maximi;
var
a,b,c,max,maximo : Real;
begin
Writeln ('Ingrese tres numeros');
Readln (a);
Readln (b);
Readln (c);
max:=((a+b)+abs(a-b))/2;
maximo:= ((max + c) + abs (max - c))/2;
Writeln ('El maximo es', maximo:10:2);
End.
EJERCICIO 4
Desarrollar un algoritmo que detecte si un numero dado es positivo o
negativo.
ANALISIS
DE: un numero real
DS: Un mensaje afirmativo si el numero es negativo
DISEO
Algoritmo Negativo
Lexico
a : R
Inicio
Escribir(Ingrese un numero)
Leer (a)
Si a >= 0 entonces
Escribir (El numero es negativo)
Sino
Escribir (Es positivo)
Fin
PASCAL
Program Negative;
Uses crt;
Var
a:real;
Begin
clrscr;
Writeln ('Ingrese un numero');
Readln (a);
If a<=0 then
Writeln ('El numero es negativo')
else
Writeln ('POSITIVO');
End.
EJERCICIO 5
Elaborar un algoritmo que lea dos nmeros desde el teclado y si el
primero es mayor que el segundo, intercambie sus valores.
ANLISIS
DE:dos nmeros reales
DS:dos nmeros reales
Debo saber que: En este caso debemos intercambiar los valores SIN
utilizar ningun tipo de variable auxiliar.
DISEO
Algoritmo Intercambiar
Lxico
a,b : R
Inicio
Escribir (Ingrese dos numero)
Leer (a,b)
Si a>b entonces
a a+b
b a-b
a a-b
Escribir (Los nmeros ingresados intercambiados son,a y, b)
Fin
PASCAL
program Intercambiar;
Uses crt;
Var
a,b : Real;
Begin
clrscr;
Writeln ('Ingrese dos numeros');
Readln (a);
Readln (b);
If a>b then
a := a+b;
b := a-b;
a := a-b;
Writeln ('Los valores intercambiados son ', a:10:2 , ' y ', b:10:2);
End.
EJERCICIO 6
Desarrollar un algoritmo que detecte si se han introducido tres
numeros en orden creciente.
ANALISIS
DE: tres numeros reales
DS: Un mensaje afirmativo si los numeros fueron ingresados en forma
creciente.
DISEO
Algoritmo creciente
Lxico
a,b,c : R
Inicio
Escribir (Ingrese tres nmeros)
Leer (a,b,c)
Si a < b < c entonces
Escribir (Los nmeros fueron ingresados en orden creciente)
sino
Escribir (No)
Fin
PASCAL
program creciente;
Uses crt;
var
a,b,c : Real;
begin
clrscr;
Writeln ('Ingrese tres numeros');
Readln (a);
Readln (b);
Readln (c);
If (a < b) and (b< c) then
Writeln ('Los numeros fueron ingresados en orden creciente')
else
Writeln ('No');
End.
EJERCICIO 7
Desarrollar un algoritmo que lea desde el teclado el importe bruto de
una factura y determine el importe neto segn los siguientes
criterios:
-Importe bruto menor a 20.000 Sin descuento
-Importe bruto mayor a 20.000 15% de descuento
ANALISIS
DE: un numero real
DS: un numero real
Debo saber que:
-Importe bruto menor a 20.000 Sin descuento
-Importe bruto mayor a 20.000 15% de descuento
DISEO
Algoritmo Importe
Lxico
importe:R
Inicio
Escribir (Ingrese el importe bruto)
Leer (importe);
Si importe > 20.000 entonces
importe importe + (importe * 0,15)
Escribir (El importe mas el descuento es, importe)
sino
importe importe
Escribir (No hay descuento el importe es, importe)
Fin
PASCAL
Program Impor;
Uses crt;
var
importe:Real;
Begin
clrscr;
Writeln ('Ingrese el importe bruto');
Readln (importe);
If importe >= 20000 then
importe := importe - (importe * 0.15);
Writeln ('El importe mas el descuento es', importe:10:2);
If importe < 20000 then
Writeln ('El importe sin descuento es', importe:10:2);
End.
EJERCICIO 8
Desarrollar un algoritmo que una vez leda una Fecha en formato
dd/mm/aaaa, indique cual sera la fecha un da despus.
ANALISIS
DE: 3 variables correspondientes a dd mm y aaaa
DS: 3 variables, correspondientes a dd mm y aaaa pero un dia despues
PASCAL
Program gdosEjentr;
Var
Mes31, Mes30, Mes28, Mes12, aniobisiesto : Boolean;
dia, mes, anio : integer;
Begin
dia := dia+01;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia < 28) and (mes28) then
Begin
dia := dia+1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia =31) and (mes31) then
Begin
dia := 01;
mes := mes +1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia = 30) and (mes30) then
Begin
dia := 01;
mes := mes +1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia = 28) and (mes28) and (Aniobisiesto) then
Begin
dia:= dia +1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia = 31) and ( mes12) then
Begin
dia:= 01;
mes:= 01;
anio:= anio +1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia < 31) and (mes12) then
Begin
dia:= dia +1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia = 28) and (mes28) then
Begin
dia := 01;
mes := mes +1;
Writeln ('La fecha un dia despues es', dia,',', mes,',', anio)
End
else begin
If (dia = 29) and (mes28) and (Aniobisiesto) then
Begin
dia := 01;
mes := mes +1;
End;
End;
End;
End;
End;
End;
End;
End;
End;
{Post-Condicion : Si (dia < 31) ^ (mes31) entonces dia, mes, anio:
Resultado0
Si (dia < 30) ^ (mes30) entonces dia, mes, anio: Resultado1
Si (dia < 28) ^ (mes28) entonces dia, mes, anio: Resultado2
Si (dia = 31) ^ (mes31) entonces dia, mes, anio: Resultado3
a
sino
si b<a<c<d entonces
b
sino
si c<a<b<d entonces
c
sino
si d<a<b<c entonces
d
Fin
PASCAL
Esta es la funcion, ATENCIN ESTE CASO ESTA TRADUCIDA SOLAMENTE LA
FUNCION POR LO QUE FALTA UNA PARTE; QUE SERIA EL DISEO DE EL ALGORIMO
QUE VA A TENER LA FUNCION DENTRO DEL LEXICO O VAR. DE ESTA FORMA NO
LES VA A COMPILAR..
Function Maximo (a,b,c,d :Real): Real;
var max, maxi :R;
Begin
max:= ((a+b)+abs(a-b))/2;
maxi:=((max+c)+abs(max-c))/2;
Maximo := ((maxi+d)+abs(maxi-d))/2;
End.
Funcion MINIMO:
Function Minimo (a,b,c,d :Real):Real;
Begin
If a<b<c<d then
Minimo:= a;
If b<a<c<d then
Minimo:= b;
If c<a<b<d then
Minimo:= c;
If d<a<c<b then
Minimo:= d;
End.
EJERCICIO 10
Desarrollar un algoritmo que permita visualizar los numeros pares
entre 1 y 25
DISEO
Algoritmo Paresentre
Lexico
Inicio
repetir
Si i mod 2 =0 entonces
Escribir (i)
i i+1;
Hasta (i=25)
Fin
PASCAL
Program Paresentre;
Var i: integer;
Begin
i:=1;
Repeat
If (i mod 2) = 0 then
begin
Writeln (i);
End;
i := i+1;
Until (i=25);
End.
EJERCICIO 10
Desarrollar un algoritmo que CALCULE EL MCM Y MCD de dos numeros:
PASCAL
Program MCMMCD;
Uses crt;
Var
a,b,a2,b2,MCM :real;
Begin
clrscr;
Repeat
Writeln ('Ingrese dos numeros');
Readln (a);
Readln (b);
until (a>0) and (b>0);
http://www.tecnohackers.net/biblioteca-tecnica-programacion-54/escuela-deprogramacion-conceptos-e-introduccion-by-smartgenius/?
PHPSESSID=0dc6e869dbbd674b649002b048383f0c
http://foro.el-hacker.com/f57/taller-ejercicios-de-programacion-estructurasselectivas-119838/