Documentos de Académico
Documentos de Profesional
Documentos de Cultura
program triangulo;
uses crt;
var
B,A,R:real;
Begin
clrscr;
writeln ('Calcula el area de un triangulo');
writeln(' ');
write ('ingrese el valor de la base:');
read(B);
write ('ingrese el valor de la altura:');
read(A);
R:=B*A/2;
writeln ('El area del triangulo es:',R:5:2);
read(R);
readln
end.
Array
program array2;
uses crt;
var arr_num: array[1..7] of integer;
var i, posi_max,val_max,num:integer;
begin
clrscr;
writeln('Escriba los 7 numeros:');
for i:=1 to 7 do
begin
readln(num);
arr_num[i]:=num;
if arr_num[i]>val_max then
begin
val_max:=arr_num[i];
posi_max:=i;
end;
end;
writeln('valor maximo:',val_max,' posicion:',posi_max);
readln
end.
program array2;
uses crt;
var arr_num: array[1..7] of integer;
var i, posi_max,val_max,num:integer;
begin
clrscr;
writeln('Escriba los 7 numeros:');
for i:=1 to 7 do
begin
readln(num);
arr_num[i]:=num;
if arr_num[i]>val_max then
begin
Arreglo
program nomvec;
uses crt;
var
i,j:integer;
nomvector:array[1..10]of integer;
begin
clrscr;
for j:=1 to 10 do
begin
i:=i+1;
nomvector[j]:=i;
writeln(nomvector[i]);
end;
readln(i);
readkey
end.
val_max:=arr_num[i];
posi_max:=i;
end;
end;
writeln('valor maximo:',val_max,' posicion:',posi_max);
readln
end.
program burbuja;
uses crt;
var
arreglo:array[1..15]of integer;
i,j,aux:integer;
begin
clrscr;
writeln('*Ingrese los datos*');
writeln;
{codigo para capturar los datos}
for i:=1 to 15 do
begin
write('Dato',i,':');
readln(arreglo[i]);
end;
{se ordenan los datos}
for i:=1 to 14 do
begin
for j:=1 to 14 do
begin
if( arreglo[j]<arreglo[j+1]) then
begin
aux:=arreglo[j];
arreglo[j+1]:=aux;
end;
end;
end;
{impresion del arreglo}
writeln('*arreglo ordenado');
for i:=1 to 15 do
begin
write('[',arreglo[i],']');
end;
readln;
readkey;
end.
program libreri;
uses
crt;
type
apilar = record
ISBN : array[1..30] of integer;
contenido : integer;
end;
var
estante : apilar;
i : integer;
tecla : char;
procedure entradatos;
begin
clrscr;
i := estante.contenido + 1;
repeat
gotoxy(10,2);write('*** N Libros = ',i - 1);
gotoxy(10,4);write('Entre ISBN : ');
gotoxy(22,4);readln(estante.isbn[i]);
estante.contenido := estante.contenido + 1;
gotoxy(10,6);write('Entra mas Libros [S/N]');
tecla := readkey;
gotoxy(10,6);clreol;
gotoxy(22,4);clreol;
i := i + 1;
if i > 30 then
tecla := 'N';
until tecla in['n','N'];
end;
procedure venta;
var
vendio : integer;
can : boolean;
begin
clrscr;
gotoxy(10,4);write('Entre ISBN Vendido : ');
gotoxy(31,4);readln(vendio);
i := 1;
can := false;
repeat
if estante.isbn[i] = vendio then
begin
estante.isbn[i] := 0;
estante.contenido := estante.contenido - 1;
can := true;
end;
i := i + 1;
until (i > estante.contenido) or (can = true);
end;
procedure anulalibro;
var
anula : integer;
sal : boolean;
begin
clrscr;
gotoxy(10,4);write('Entre ISBN a Anular : ');
gotoxy(31,4);readln(anula);
i := 1;
sal := false;
repeat
if estante.isbn[i] = anula then
begin
estante.isbn[i] := 0;
estante.contenido := estante.contenido - 1;
sal := true;
end;
i := i + 1;
until (sal = true) or (i > 30);
if sal = false then
begin
gotoxy(10,8);write('El libro Anulado No Existia Pulse [Enter]');
readln;
end;
end;
procedure presenta5ultimos;
var
s, cont : integer;
begin
clrscr;
cont := estante.contenido;
if cont < 5 then
begin
for i := 1 to cont do
begin
gotoxy(10,4 + i);write('ISBN : ',estante.isbn[i]);
end;
end
else
begin
i := cont - 4;
s := 0;
repeat
gotoxy(10,4 + s);write('ISBN : ',estante.isbn[i]);
i := i + 1;
s := s + 1;
until i > cont;
end;
gotoxy(10,12);write('Pulse [Enter]');
readln;
end;
procedure menu;
var
pulsa : char;
begin
clrscr;
textcolor(15);
gotoxy(5,4);write('***** Menu General *****');
gotoxy(5,6);write(' 1 = Entra Libros ');
gotoxy(5,8);write(' 2 = Anula Libro ');
gotoxy(5,10);write(' 3 = Presenta 5 Ultimos ');
gotoxy(5,12);write(' 4 = Ventas ');
gotoxy(5,14);write(' 5 = Salir ');
gotoxy(5,18);write('**** Elija Opcion ****');
gotoxy(15,18);
repeat
pulsa := readkey;
case pulsa of
#49 : entradatos;
#50 : anulalibro;
#51 : presenta5ultimos;
#52 :;
end;
clrscr;
textcolor(15);
gotoxy(5,4);write('***** Menu General *****');
gotoxy(5,6);write(' 1 = Entra Libros ');
gotoxy(5,8);write(' 2 = Anula Libro ');
gotoxy(5,10);write(' 3 = Presenta 5 Ultimos ');
gotoxy(5,12);write(' 4 = Ventas ');
gotoxy(5,14);write(' 5 = Salir ');
gotoxy(5,18);write('**** Elija Opcion ****');
gotoxy(15,18);
until pulsa = #53;
clrscr;
end;
begin
clrscr;
fillchar(estante,sizeof(estante),0);
menu;
end.
program clinica;
uses
crt;
type
paciente = record
nombre : string[80];
numero : integer;
end;
var
lista : array[1..20] of paciente;
x, y, i : integer;
function entrada(x, y : integer) : string;
var
tecla : char;
da : integer;
dat : string[30];
begin
da := 1;
repeat
tecla := readkey;
if upcase(tecla) in[#65..#90,#165,#32] then
begin
dat[da] := tecla;
dat[0] := chr(da);
gotoxy(x + da,y);write(dat[da]);
da := da + 1;
if da > 80 then
da := 80;
end;
if tecla = #8 then
begin
da := da - 1;
if da < 1 then
da := 1;
dat[da] := ' ';
dat[0] := chr(da);
gotoxy(x + da,y);write(' ');
end;
until (tecla = #13) or (tecla = #27);
if tecla <> #27 then
entrada := copy(dat,1,length(dat));
end;
procedure entradadatos;
var
cont : integer;
pulsada : char;
entramas, fin : boolean;
begin
clrscr;
cont := 1;
fin := false;
i := 1;
entramas := false;
repeat
x := 27;
y := 4;
gotoxy(1,4);write('Entre Nombre Y Apellidos : ');
lista[cont].nombre := entrada(x,y);
lista[cont].numero := cont;
clrscr;
repeat
gotoxy(10,20);write('Entra Mas Personas [S/N]');
pulsada := readkey;
if upcase(pulsada) <> 'N' then
begin
cont := cont + 1;
if cont > 20 then
fin := true;
clrscr;
entramas := true;
end;
until (entramas = true) or (upcase(pulsada) = 'N') or (fin = true);
if entramas = true then
entramas := false;
until (upcase(pulsada) = 'N') or (fin = true);
end;
procedure lista_personas;
var
nu : integer;
begin
nu := 0;
clrscr;
for i := 1 to 20 do
begin
if lista[i].numero > 0 then
nu := nu + 1;
end;
for i := 1 to nu do
begin
gotoxy(3,4 + i);write('[',lista[i].numero,'] ',lista[i].nombre);
end;
readln;
end;
procedure menu;
var
opcion : char;
begin
gotoxy(3,3);write('**** Menu General ****');
gotoxy(3,5);write(' 1 = Entrada Datos Persona');
gotoxy(3,6);write(' 2 = Lista De Persona');
gotoxy(3,7);write(' 3 = Salir');
gotoxy(3,10);write(' <<< Elija Opcion >>>');
repeat
opcion := readkey;
case opcion of
'1' : entradadatos;
'2' : lista_personas;
end;
if opcion <> '3' then
begin
clrscr;
gotoxy(3,3);write('**** Menu General ****');
gotoxy(3,5);write(' 1 = Entrada Datos Persona');
gotoxy(3,6);write(' 2 = Lista De Persona');
gotoxy(3,7);write(' 3 = Salir');
gotoxy(3,10);write(' <<< Elija Opcion >>>');
end;
until opcion = '3';
end;
begin
clrscr;
menu;
end.
Ciclos
program ciclorepe;
uses crt;
var num,num2:integer;
begin
clrscr;
num:=1;
repeat
begin
writeln(num);
num:=num+1;
end
until num = 11;
num2:=11;
repeat
begin
num2:=num2-1;
writeln(num2);
end
until num2 = 1;
readkey;
readln;
end.
program ciclomientras;
uses crt;
var i,x,num1,num2:integer;
begin
clrscr;
i:=0;
num1:=0;
while i<10 do
begin
i:=i+1;
num1:=num1+1;
writeln(num1);
end;
x:=10;
num2:=11;
while x>=1 do
begin
x:=x-1;
num2:=num2-1;
writeln(num2);
end;
readkey;
end.
program ciclo30;
uses crt;
var
a, num: integer;
begin
clrscr;
a:=0;
for a:=0 to 29 do
begin
num:=num+1;
writeln (num);
end;
for a:=29 downto 0 do
begin
num:=num-1;
writeln(num);
end;
readkey;
readln;
end.
program ciclo;
uses crt;
var
I,num:integer;
begin
clrscr;
I:=0;
num:=0;
for I:=0 to 9 do
begin
num:=num+1;
writeln(num);
end;
readln
end.
program casel;
uses crt;
var
letra:char;
begin
clrscr;
gotoxy(20,5);
write('Ingrese una letra:');
readln;
{empieza case}
case letra of
'A': begin
gotoxy(50,5);
write('Aguila');
readln;
end;
'B':begin
gotoxy(50,5);
write('Becerro');
readln;
end;
'C':begin
gotoxy(50,5);
write('Caballo');
readln;
end;
else
begin
gotoxy(50,5);
write('No hay esa letra');
readln;
end;
end;
readln;
readkey;
end.
program futbol;
uses crt;
var
opcion:integer;
begin
clrscr;
writeln
('Elige un equipo');
writeln('1.-Real madrid');
writeln('2.-Barcelona');
writeln('3.-Milan');
writeln('4.-Inter');
writeln('5.-Bayern munich');
writeln('6.-Chelsea');
writeln('7.-Manchester united');
writeln('8.-America');
readln(opcion);
case opcion of
1:write('Campeon de Espaa');
2:write('Campeon de Europa');
3:write('Lider de la liga ');
4:write('Segundo lugar de la liga');
5:write('El mejor equipo de Alemania');
6:write('Campeon de Inglaterra');
7:write('Campeon de Copa');
8:write('El mejor equipo de mexico ');
else
write('ERROR opcion invalida');
end;
readln;
readkey;
end.
program futbol;
uses crt;
var
opcion:integer;
begin
clrscr;
writeln
('Elige un equipo');
writeln('1.-leones negros');
writeln('2.-america');
writeln('3.-atlas');
writeln('4.-leon');
writeln('5.-pumas');
writeln('6.-toluca');
writeln('7.-chivas');
writeln('8.-tecos');
readln(opcion);
case opcion of
1:write('el mejor equipo de jalisco');
2:write('el equipo con mas mercadotecnia');
3:write('lo peor de jalisco');
4:write('equipo de tradicion');
5:write('lo mejor de df');
6:write('equipo con historia');
7:write('basura despues de vergara');
8:write('en el olvido');
else
write('ERROR opcion invalida');
end;
readln;
readkey;
end.
program ejemplo1;
uses crt;
var arr_num:array [1..5] of real;
var i, num:integer;
var media:real;
begin
clrscr;
writeln ('escriba 5 numeros para hacer su media arimetica:');
for i:= 1 to 5 do
begin
readln(num);
arr_num[i]:=num;
end;
for i:= 1 to 5 do
media:= media + arr_num[i];
media:= media / i;
writeln ('la media arimetica es:',media:5:2);
end.
program ejer10;
uses crt;
const arr_num:array [1..4,1..2]of integer=((3,2),(4,6),
(8,9),(0,0));
var i,j,suma1,suma2:integer;
begin
clrscr;
for j:=1 to 2 do
begin
for i:=1 to 4 do
begin
if j=1 then suma1:= suma1 + arr_num[i,j];
if j=2 then suma2:= suma2 + arr_num[i,j];
end;
end;
writeln ('el resultado de la suma1 es:',suma1);
writeln ('el resultado de la suma2 es:',suma2);
readkey
end.
program ejer9;
uses crt;
const arr_num:array [1..2,1..6] of integer=((3,6,9,7,8,0),
(1,4,3,2,7,0));
var i,j,suma1, suma2:integer;
begin
clrscr;
for i:=1 to 2 do
begin
for j:=1 to 6 do
begin
if i=1 then suma1:= suma1 + arr_num[1,j];
if i=2 then suma2:= suma2 + arr_num[2,j];
end;
end;
writeln ('la suma de la fila 1 es:',suma1);
writeln ('la suma de la fila 2 es:',suma2);
readkey
end.
program ejer8;
uses crt;
const arr_num:array [1..2,1..5] of integer=((3,6,7,8,9),
(0,0,0,0,0));
var i,j,cuad:integer;
begin
clrscr;
i:=1;
for j:=1 to 5 do
begin
for i:=1 to 1 do
begin
cuad:=sqr(arr_num[i,j]);
arr_num[2,j]:= cuad;
writeln (arr_num[2,j]);
readkey
end;
end;
end.
program ejer7;
uses crt;
const arr_num:array[1..3,1..3] of integer=((-12,23,32),
(45,-56,-10),
(25,78,89));
var i,j,suma_pos,suma_neg:integer;
begin
suma_pos:=0;
suma_neg:=0;
clrscr;
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
if arr_num[i,j] < 0 then
suma_pos:=suma_neg+arr_num [i,j]
else
suma_pos:=suma_pos+arr_num[i,j]
end;
end;
writeln('suma positivos:', suma_pos:5);
writeln('suma negativos:', suma_neg:5);
readkey
end.
program ejer6;
uses crt;
const arr_num:array[1..3,1..3] of integer=((4,5,8),
(6,9,1),
(5,0,3));
var i,j:integer;
begin
clrscr;
for i:=1 to 3 do
for j:=1 to 3 do
arr_num[i,j]:=arr_num[i,j]*2;
for i:=1 to 3 do
begin
for j:=1 to 3 do
write(arr_num[i,j]:3);
writeln ('');
readkey
end;
end.
program ejer5;
uses crt;
const arr_num:array[1..3,1..3] of integer=((23,45,68),
(34,99,12),
(25,78,89));
var i,j,val_max,pos_max_i,pos_max_j:integer;
begin
clrscr;
val_max:=arr_num[1,1];
for i:= 1 to 3 do
begin
for j:= 1 to 3 do
begin
if arr_num[i,j] > val_max then
begin
val_max:=arr_num[i,j];
pos_max_i:=i;
pos_max_j:=j;
end;
end;
end;
writeln('valor maximo:', val_max:3,
'posicion:',pos_max_i:3,pos_max_i:3);
end.
program ejer4;
uses crt;
const arr_num:array[1..7] of integer=(23,45,68,99,10,15,4);
var i,val_max,val_min,pos_max,pos_min:integer;
begin
clrscr;
val_min:=arr_num[1];
val_max:=arr_num[1];
for i:= 1 to 7 do
begin
if arr_num[i] > val_max then
begin
val_max:=arr_num[i];
pos_max:=i;
end;
if arr_num[i] < val_min then
begin
val_min:=arr_num[i];
pos_min:=i;
end;
end;
writeln('valor maximo:',val_max,'posician:',pos_max:3);
writeln('valor maximo:',val_max,'posician:',pos_max:3);
end.
program ejer3;
uses crt;
const arr_num:array [1..7] of integer=(-2,5,8,-9,10,15,-4);
var i:integer;
var suma_p, suma_n:integer;
begin
clrscr;
for i:= 1 to 7 do
begin
if arr_num[i] >= 0 then
suma_n:= suma_n + arr_num[i]
else if arr_num[i] < 0 then
suma_n:= suma_n + arr_num[i];
end;
writeln ('la suma de los numeros positivos es:',suma_p);
writeln ('la suma de los numeros negativos es:',suma_n);
end.
program ejercicio2;
uses crt;
const arr_num:array[1..7] of integer=(23,45,68,99,10,15,4);
var i,posi_max,val_max:integer;
begin
clrscr;
for i:= 1 to 7 do
begin
if arr_num[i] > val_max then
begin
val_max:=arr_num[i];
posi_max:=i;
end;
end;
write('valor maximo:',val_max,'posicion:',posi_max);
end.
program ciclo2;
uses crt;
var i,x,num1,num2:integer;
begin
clrscr;
i:=0;
num1:=0;
for i:=1 to 9 do
begin
num1:=num1+1;
writeln(num1);
end;
x:=9;
num2:=9;
for x:=9 downto 1 do
begin
writeln(num1);
num1:=num1-1;
end;
readkey;
end.
Cola
program pilafifo;
uses
crt;
type
pfifo = ^rfifo;
rfifo = record
dato : integer;
sig : pfifo;
end;
var
prim, ultim, actu : pfifo;
regfi : rfifo;
function entrada : integer;
var
num : integer;
begin
num := 0;
clrscr;
write(' Entre N : ');
readln(num);
entrada := num;
end;
procedure inicionil;
begin
prim := nil;
ultim := nil;
end;
procedure crearinserta;
begin
new(actu);
actu^.dato := entrada;
actu^.sig := nil;
if ultim <> nil then
begin
ultim^.sig := actu;
ultim := actu;
end
else
begin
prim := actu;
ultim := actu;
end;
end;
procedure borradofifo;
var
punt, borra : pfifo;
begin
if prim = ultim then
begin
borra := prim;
dispose(borra);
prim := nil;
ultim := nil;
end
else
begin
borra := prim;
prim := borra^.sig;
dispose(borra);
end;
end;
procedure muestrafifo;
var
punt : pfifo;
begin
punt := prim;
while punt <> nil do
begin
write(' ',punt^.dato);
punt := punt^.sig;
end;
readkey;
end;
procedure suma;
var
sum : integer;
punt : pfifo;
begin
write(' Sumar El Primero Por N : ');
readln(sum);
punt := prim;
writeln(' La Suma De [ ',sum,' ] Y [ ',punt^.dato,' ] Es : ',
Sum + punt^.dato);
writeln;
writeln(' Pulse Una Tecla');
readkey;
borradofifo;
end;
procedure Resta;
var
res : integer;
punt : pfifo;
begin
write(' Restar El Primero Del N : ');
readln(res);
punt := prim;
writeln(' La Resta De [ ',punt^.dato,' ] Y [ ',res,' ] Es : ',
punt^.dato - res);
writeln;
writeln(' Pulse Una Tecla');
readkey;
borradofifo;
end;
procedure multiplica;
var
mul : integer;
punt : pfifo;
begin
write(' La Multiplicacion Del Primero Por N : ');
readln(mul);
punt := prim;
writeln(' La Multiplicacion De [ ',punt^.dato,' ] Y [ ',mul,' ] Es
: ',
punt^.dato * mul);
writeln;
writeln(' Pulse Una Tecla');
readkey;
borradofifo;
end;
procedure division;
var
divi : integer;
punt : pfifo;
begin
write(' La Division Del Primero Por N : ');
readln(divi);
punt := prim;
writeln(' La Division De [ ',punt^.dato,' ] Y [ ',divi,' ] Es : ',
punt^.dato / divi:0:2);
writeln;
writeln(' Pulse Una Tecla');
readkey;
borradofifo;
end;
procedure procesodedatos;
var
te : char;
fuera : boolean;
begin
fuera := false;
repeat
clrscr;
writeln(' **** Procesos a Elejir ****');
writeln;
writeln(' [S] = Sumar');
writeln(' [R] = Restar');
writeln(' [M] = Multiplicar');
writeln(' [D] = Dividir');
writeln(' [F] = Salir');
writeln;
writeln(' <<< Elija Opcion >>>');
te := upcase(readkey);
case te of
'S' : begin clrscr; suma; end;
'R' : begin clrscr; Resta; end;
'M' : begin clrscr; multiplica; end;
'D' : begin clrscr; division; end;
'F' : fuera := true;
end;
until fuera = true;
end;
procedure menu;
var
tec : char;
sal : boolean;
begin
sal := false;
repeat
clrscr;
writeln(' ***** Menu Principal *****');
writeln;
writeln(' 1 = Crear O Insertar En Cola');
writeln(' 2 = Mostrar Todos');
writeln(' 3 = Procesar Datos');
writeln(' 4 = Borrar Primer Elemento');
writeln(' F = Salir');
writeln;
writeln(' <<< Elija Opcion >>>');
tec := upcase(readkey);
case tec of
'1' : begin clrscr; crearinserta; end;
'2' : begin clrscr; muestrafifo; end;
'3' : begin clrscr; procesodedatos; end;
'4' : begin clrscr; borradofifo; end;
'F' : sal := true;
end;
until sal = true;
end;
begin
inicionil;
menu;
if prim <> nil then
dispose(actu);
end.
program matrizmlt;
uses crt;
const
arr_num:array[1..3,1..3]of integer=((4,7,8),(6,9,1),(5,0,3));
var
mult,i,j:integer;
begin
clrscr;
for i:=1 to 3 do
begin
forj:=1 to 3 do
begin
mult:=arr_num[i,j]*2;
writeln('Elemento(',i,','j,')multiplicado por2:',mult:3);
end;
end;
readln;
readkey;
end.
program matria;
uses crt;
const
arr_num:array[1..2,1..6] of integer
=((3,6,9,7,8,0),(1,4,3,2,7,0));
var
i,j,suma1,suma2:integer;
begin
clrscr;
for i :=1 to 2 do
begin
for j:=1 to 6 do
begin
if i=1 then
suma1:=suma1+arr_num[1,j];
if i=2 then
suma2:= suma2+arr_num[2,j];
end;
end;
writeln('La suma de la fila 1 es:',suma1);
writeln('La suma de la fila 2 es:',suma2);
readln;
readkey;
end.
program equipos;
uses crt;
var
equipo1,equipo2:integer;
nombre1,nombre2:string;
begin
clrscr;
write('Introduce el nombre del primer equipo:');
read(nombre1);
readln;
write('Introduce el nombre del segundo equipo:');
read(nombre2);
readln;
writeln('-----------------------------------------');
writeln('******************Marcador***************');
writeln('-----------------------------------------');
write(nombre1);
write(':');
read(equipo1);
readln;
write(nombre2);
write(':');
read(equipo2);
readln;
if equipo1 > equipo2 then
begin
writeln('------------------------------------------');
writeln('***************Equipo ganador*************');
writeln('------------------------------------------');
writeln('Ganador:',nombre1);
read(nombre1);
end;
if equipo1 < equipo2 then
begin
writeln('***************Marcador*************');
readln;
writeln('Ganador:',nombre2);
read(nombre2);
end
end.
Program factura;
uses crt;
var
QTY,PU,SBTL,IVA,TL:REAL;
Begin
clrscr;
write('Cantidad a comprar');
read(QTY);
write('Introduzca el precio unitario');
read(PU);
SBTL:=QTY*PU;
IVA:=SBTL*0.16;
TL:=SBTL+IVA;
write('El subtotal es:',SBTL:8:2);
write(' ');
write('El IVA es:',IVA:4:2);
write(' ');
write('El total es:',TL:8:2);
read(TL);
readln;
end.
program estructu;
uses
crt;
type
puntlibreta = ^libreta;
libreta = record
numero : word;
sig : puntlibreta;
end;
var
alumno, alumno1, alumno2 : puntlibreta;
function datos : word;
var
tecla : char;
dnume : string[10];
error, cont : integer;
num : word;
begin
cont := 1;
fillchar(dnume,11,' ');
dnume[0] := chr(10);
datos := 0;
gotoxy(5,5);write('Entre el N Libreta Universitaria : ');
gotoxy(41,5);
repeat
tecla := readkey;
if tecla in[#48..#57] then
begin
dnume[cont] := tecla;
dnume[0] := chr(cont);
gotoxy(40 + cont,5);write(dnume[cont]);
cont := cont + 1;
if cont > 10 then
cont := 10;
end;
if tecla = #8 then
begin
cont := cont - 1;
if cont < 1 then
cont := 1;
dnume[cont] := ' ';
dnume[0] := chr(cont);
gotoxy(40 + cont,5);write(dnume[cont]);
end;
until tecla = #13;
if cont > 1 then
begin
val(dnume,num,error);
datos := num;
end;
end;
procedure entrada;
begin
if alumno1 = nil then
begin
new(alumno);
alumno^.numero := datos;
alumno1 := alumno;
alumno^.sig := nil;
end
else
begin
alumno2 := alumno;
new(alumno);
alumno^.numero := datos;
alumno2^.sig := alumno;
alumno^.sig := nil;
end;
end;
procedure listar_alumnos;
var
alum : puntlibreta;
xn, yn : integer;
begin
xn := 15;
yn := 3;
alum := alumno1;
gotoxy(xn, yn - 2);write('*** Alumnos ***');
repeat
gotoxy(xn, yn);write(alum^.numero);
yn := yn + 1;
if yn > 24 then
begin
writeln;
yn := yn - 1;
end;
alum := alum^.sig;
until alum = nil;
readln;
end;
procedure marcador(xm, ym : integer; estado : boolean);
begin
if estado = true then
begin
gotoxy(xm,ym);write('----------------');
gotoxy(xm - 1,ym + 1);write(':');
gotoxy(xm + 16,ym + 1);write(':');
gotoxy(xm,ym + 2);write('----------------');
end
else
begin
gotoxy(xm,ym);write(' ');
gotoxy(xm - 1,ym + 1);write(' ');
gotoxy(xm + 16,ym + 1);write(' ');
gotoxy(xm,ym + 2);write(' ');
end;
end;
procedure menualumnos;
var
opcion, xp, yp : integer;
tec : char;
salir : boolean;
begin
clrscr;
xp := 9;
yp := 6;
opcion := 1;
salir := false;
gotoxy(10,5);write('**** Menu Alumnos ****');
gotoxy(10,7);write('Crear Lista');
gotoxy(10,9);write('Insertar Lista');
gotoxy(10,11);write('Recorrer Lista');
gotoxy(10,13);write('Longitud Lista');
gotoxy(10,15);write('Eliminar Alumno');
gotoxy(10,17);write('Buscar Alumno');
gotoxy(10,19);write('Eliminar Todo');
gotoxy(10,21);write('Salir');
marcador(xp,yp,true);
repeat
tec := readkey;
marcador(xp,yp,false);
if tec = #80 then
begin
opcion := opcion + 1;
if opcion > 8 then
opcion := 8;
yp := yp + 2;
if yp > 20 then
yp := 20;
end;
if tec = #72 then
begin
opcion := opcion - 1;
if opcion < 1 then
opcion := 1;
yp := yp - 2;
if yp < 6 then
yp := 6;
end;
if tec = #13 then
begin
clrscr;
case opcion of
1 : entrada;
2 :;
3 : listar_alumnos;
4 :;
5 :;
6 :;
7 :;
8 : salir := true;
end;
clrscr;
gotoxy(10,5);write('**** Menu Alumnos ****');
gotoxy(10,7);write('Crear Lista');
gotoxy(10,9);write('Insertar Lista');
gotoxy(10,11);write('Recorrer Lista');
gotoxy(10,13);write('Longitud Lista');
gotoxy(10,15);write('Eliminar Alumno');
gotoxy(10,17);write('Buscar Alumno');
gotoxy(10,19);write('Eliminar Todo');
gotoxy(10,21);write('Salir');
end;
marcador(xp,yp,true);
until salir = true;
end;
begin
clrscr;
textcolor(15);
alumno1 := nil;
menualumnos;
end.
program incwhile;
uses crt;
var
i,d:integer:
begin
clrscr;
i:=1;
d:=0;
while i <=10 do
begin
writeln(i);
i:=i=1;
readln;
end;
while i>=10 do
begin
i:=i-1;
writeln(i);
readln;
end;
readln
end.
program incwhile;
uses crt;
var
i,d:integer;
begin
clrscr;
i:=1;
d:=0;
while i <=10 do
begin
writeln(i);
i:=i+1;
readln;
end;
while i>=10 do
begin
i:=i-1;
writeln(i);
readln;
end;
readln
end.
uses
crt;
{Esto seria la pila}
type
lapila = ^elnodopila;
elnodopila = record
dia, mes, ano : longint;
ced : string;
nom : string ;
ape : string ;
mon, tipo : integer;
cuent : integer ;
depo : integer;
sig : lapila
end;
var
pil : elnodopila;
procedure iniciapila(var pila: lapila);
begin
pila := nil
end;
function pilavacia(pila : lapila): boolean;
begin
pilavacia := pila = nil
end;
procedure entada_datos(var eldato : elnodopila);
begin
writeln('***** Entrada Datos *****');
writeln;
write(' Entre Dia : ');
readln(eldato.dia);
write(' Entre Mes : ');
readln(eldato.mes);
write(' Entre Ao : ');
readln(eldato.ano);
write(' Entre Cedula : ');
readln(eldato.ced);
write(' Entre Nombre : ');
readln(eldato.nom);
write(' Entre Apellido : ');
readln(eldato.ape);
write(' Entre Monton : ');
readln(eldato.mon);
write(' Entre Tipo : ');
readln(eldato.tipo);
write(' Entre Cuente : ');
readln(eldato.cuent);
write(' Entre Deposito : ');
readln(eldato.depo);
end;
procedure anadirapila(datos : elnodopila; var pila: lapila);
var
auxil : lapila;
begin
auxil := pila;
New(pila);
pila^ := datos;
pila^.sig := auxil
end;
procedure anulaPila(var pila : lapila);
var
auxil : lapila;
begin
auxil := pila;
pila := pila^.sig;
dispose(auxil)
end;
{Esto seria la cola}
type
nodocola = ^lacola;
lacola = record
dia, mes, ano : longint;
ced : string;
nom : string ;
ape : string ;
mon, tipo : integer;
cuent : integer ;
depo : integer;
sige : nodocola;
end;
puntcola = record
primero: nodocola;
fin : nodocola;
end;
procedure iniciocola(var cola: puntcola);
begin
cola.primero := nil;
cola.fin := nil;
end;
procedure entradaacola(dato: lacola; var cola : puntcola);
var
auxi : nodocola;
begin
New(auxi);
auxi^ := dato;
auxi^.sige := nil;
if cola.fin <> nil then
begin
cola.fin^.sige := auxi;
cola.fin := auxi;
end
else
begin
cola.primero := auxi;
cola.fin := auxi;
end;
end;
procedure anulardecola(var cola : puntcola);
var
auxi : nodocola;
begin
if cola.primero = cola.fin then
begin
auxi := cola.primero;
dispose(auxi);
cola.primero := nil;
cola.fin := nil;
end
else
begin
auxi := cola.primero;
cola.primero := auxi^.sige;
dispose(auxi)
end;
end;
procedure MostrarCola(cola: puntcola);
var
auxi : nodocola;
begin
if cola.fin = nil then
WriteLn('Cola Vacia')
else
begin
auxi := cola.primero;
repeat
WriteLn(' Fecha = ',auxi^.dia,'/',auxi^.mes,'/',auxi^.ano);
writeln(' Cedula = ',auxi^.ced);
writeln(' Nombre = ',auxi^.nom);
writeln(' Apellido = ',auxi^.ape);
writeln(' Monton = ',auxi^.mon);
writeln(' Tipo = ',auxi^.tipo);
writeln(' Cuenta = ',auxi^.cuent);
writeln(' Deposito = ',auxi^.depo);
writeln;
writeln('*** Pulse Una Tecla ***');
readkey;
clrscr;
auxi := auxi^.sige;
until auxi = nil;
writeln;
writeln('<<<< Final De Datos >>>>');
readkey;
end;
end;
begin
end.
program mediavectur;
uses crt;
var
numeros: array [1..10] of integer;
i,suma:integer;
begin
GOTOxy (1, 1);
clrscr;
for i:= 1 to 10 do
begin
write('introduca el numero',i,':');
readln(numeros[i]);
end;
suma:=0;
for i:= 1 to 10 do
suma:= suma+numeros[i];
writeln ('la media de los 10 numeros es:',(suma/10):0:2);
write ('pulse una tecla para finalizar....');
readln;
readkey;
end.
program promedio;
uses crt;
var
calmat,calesp,callit,calinf,calder,prom:real;
begin
clrscr;
write('Introduce la calificacion de Matematicas');
read(calmat);
write('introduce la calificacion de Espaol');
read(calesp);
write('Introduce la calificacion de Literatura');
read(callit);
write('Introduce la calificacion de Informatica');
read(calinf);
write('Introduce la calificacion de Derecho');
read(calder);
prom:=(calmat+calesp+callit+calinf+calder)/5;
write('Promedio general:',prom:2:2);
read(prom);
readln;
end.
program registro;
uses crt;
type
alumnos = RECORD
clave:integer;
nombre:string[30];
estatura:real;
end;
var
alumno:alumnos;
BEGIN
clrscr;
(* capturando registro *)
write('dame clave : ');readln(alumno.clave);
write('dame nombre : ');readln(alumno.nombre);
write('dame estatura : ');readln(alumno.estatura);
(* operaciones *)
alumno.estatura := alumno.estatura + 0.23456;
(* despliegue *)
writeln;writeln;
writeln('clave : ',alumno.clave);
writeln('nombre : ',alumno.nombre);
writeln('estatura : ',alumno.estatura:0:2);
readln;
END.
program RECORD2;
uses crt;
type
alumnos = RECORD
clave:integer;
nombre:string[30];
estatura:real;
end;
var
alumno:alumnos;
archivo: file of alumnos;
temporal: file of alumnos;
clave:integer;
BEGIN
(* creando y abriendo los dos archivos *)
assign(archivo,'c:\prog\alumnos.dat');
reset(archivo);
assign(temporal,'c:\prog\temporal.dat');
rewrite(temporal);
(* capturando clave a editar *)
clrscr;
write('clave a editar : ');readln(clave);
(* iniciando ciclo de lectura de registros en archivo original *)
while not(EOF(archivo)) do
begin
READ(archivo,alumno);
if clave = alumno.clave then
begin
(* capturando nuevos datos *)
write('dame nueva clave : ');readln(alumno.clave);
write('dame nuevo nombre: ');readln(alumno.nombre);
write('dame estatura : ');readln(alumno.estatura);
(* escribiendo reg editado a temporal *)
WRITE(temporal,alumno);
end
else
WRITE(temporal,alumno);
end;
(* cerrando archivos *)
close(archivo);
close(temporal);
(* borrando y eliminando archivos *)
erase(archivo);
rename(temporal,'c:\prog\alumnos.dat');
(* avisando *)
write('Registro Editado <enter> para continuar');
readln;
END.
program repea;
uses crt;
var num:integer;
begin
clrscr;
num:=1;
repeat
begin
writeln(num);
num:=num+1;
end;
until num =11;
readln
end.
repeat
program ciclo;
uses crt;
var
num,num2:integer;
begin
clrscr;
num:=1;
repeat
begin
writeln(num);
num:=num+1;
end
until num=11;
num2:=11;
repeat
begin
writeln(num2);
num2:=num2-1;
readkey;
readln
end.
program semana;
uses crt;
var
dia:integer;
begin
clrscr;
gotoxy(4,2);
write('Introduce el dia de la semana');
readln(dia);
gotoxy(4,4);
case dia of
1:write('Lunes');
2:write('Martes');
3:write('Mierdcoles');
4:write('Jueves');
5:write('Viernes');
6:write('Sabado');
7:write('Domingo');
else
write('Error:Dia incorrecto');
end;
readln;
readkey;
end.
program comision;
uses crt;
const sueldobase=7500;
var
empleado1,empleado2:string;
venta1,venta2,comision1,comision2:real;
begin
clrscr;
write('introduce el nombre del empleado A');
read(empleado1);
write('introduce el monto de las ventas');
read(venta1);
write('introduce el nombre del empleado B');
read(empleado2);
write('introduce el monto de las ventas');
read(venta2);
readln;
if venta1 & venta2 >=5000 then
begin
comision1:=venta1*0.20;
comision2:=venta2*0.20;
write('Nombre:,'empleado1);
read(empleado1);
write(Sueldo base:',sueldobase:8:2);
read(sueldobase);
write('Venta,'venta1:8:2);
read(venta1);
comision('comision:',comision1:8:2);
read(comision1);
write('Nombre:,'empleado2);
read(empleado2);
write(Sueldo base:',sueldobase:8:2);
read(sueldobase);
write('Venta,'venta2:8:2);
read(venta2);
comision('comision:',comision2:8:2);
read(comision2);
readln;
end
else
begin
comision1:=venta1*0.10;
comision2:=venta2*0.10;
write('Nombre:,'empleado1);
read(empleado1);
write('Venta,'venta1:8:2);
read(venta1);
comision('comision:',comision1:8:2);
read(comision1);
write('Nombre:,'empleado2);
read(empleado2);
write('Venta,'venta2:8:2);
read(venta2);
comision('comision:',comision2:8:2);
read(comision2);
readln;
end;
readln; readln;
end.
Program suma;
uses CRT;
var
a,b,c,d:Integer;
Begin
clrscr;
write('Dame el valor de A:');
read (A);
write ('Dame el valor de B:');
read (B);
write ('Dame el valor de C:');
read (C);
D:=A+b+c;
writeln ('El resultado de la suma es:',D);
read(D);
readln
end.
program utilidad;
uses crt;
var
ing,egr,util,ietu:real;
begin
clrscr;
write('introduzca el total de ingresos de la empresa');
read(ing);
write('Introduzca el total de egresos de la empresa');
read(egr);
util:=ing-egr;
if util>=50000 then
begin
ietu:=util*0.20;
util:=util-ietu;
write('Utilidad:',util:18:2);
readln;
write('IETU:',ietu:18:2);
read(ietu);
readln;
end
else
begin
write('Utilidad:',util:18:2);
end;
readln; readln;
end.