Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Pascal
Pascal
1)
2) Cargar cada una de las palabras del fichero en un arreglo de registros, cada registro deber
tener
dos campos el primero de tipo numrico entero contiene el numero de orden de las palabras y
el segundo campo contiene las palabras de las frases.
3) Ordenar y mostrar el arreglo de registro en forma ascendente por el segundo campo (las
palabras)
Mediante el mtodo de ordenacin shell
*****************************************************
Parcial:
A) Realice un programa modular.
En un arreglo hay registros que tiene 2 campos
*) c1 (cadena) que representa algunas localidades de Crdoba.
*) c2 (entero) que representa la precipitacin en milmetros los siguientes datos.
1) Mostrar los datos ordenados por c2 en forma descendente por el mtodo shell.
2) Mostrar la cantidad se produjo la mayor precipitacin.
B) Crear un fichero en el block de nota y cargar versos, mostrar mediante el programa lazarus los
datos del fichero y la cantidad de caracteres que tiene cada lnea.
LES DEJO TODO EL MATERIAL QUE TENGO.Espero que les sea de utilidad a todos los que hacen
esta materia y en especial a los que visitan esta pagina que de una u otra forma nos ayuda a
todos.Ademas espero que se sumen a esto de compartir la informacion que disponen y avisen a
sus compaeros que no saben sobre estos ejercicios,luego estare subiendo otro material que
tengo de extructura de datos,disfrutenlo,y disculpen la improlijidad,soy nuevo haciendo
posts.Saludos!!!
********************************************************************************
*************************
********************************************************************************
************************
TP2_ EJERCICIO 3
program HOTEL;
uses
crt;
const
max=1000;
type
Fechas=record
dia:Integer;
mes:Integer;
anio:Integer;
end;
Datos=record
cedula:integer;
apenom:string;
valor:real;
tasa:real;
fecpres:fechas;
End;
vector=array[1..max] of datos;
Var
n,r:integer;
v:vector;
writeln('Ingrese anio:');
readln(anio);
end;
end;
end;
para i:=1 to n do
if v[i].cedula=ced then
begin
ban:=true;
writeln(el interes pagado es: ', interes(v[i]):8:2)
end;
if ban=false then
write('clinete inexixtente');
end;
begin
cargarhotel(v,n);
repeat
clrscr;
writeln('_________________MENU________________');
writeln('1.Mostrar Habitaciones Disponibles y ocupar una');
writeln('2.Mostrar datos del cliente de una habitacion');
writeln('3.Agregar un mensaje');
writeln('4.Salir');
write('Elija una Opcion: ');
readln(r);
case r of
1:MostrarLibre(v);
2:MostrarDatos(v);
3:Msj(v);
end;
until (r=4);
end.
********************************************************************************
*****************************
********************************************************************************
************************
TP2_ EJERC 4
program project1;
uses
crt;
const
max=1000;
type
Fechas=record
dia:Integer;
mes:Integer;
anio:Integer;
end;
Datos=record
Nombre:string;
apellido:string;
dni:String;
tel:string;
End;
Habitacion=record
Numero:integer;
piso:integer;
Tipo:Char;
Estado:Char;
Dper:Datos;
ingreso:Fechas;
egreso:Fechas;
Mensaje:String;
precio:real;
end;
vector=array[1..max] of Habitacion;
Var
n,r:integer;
v:vector;
begin
n:=0;
write('Ingrese cantidad de pisos del hotel: ');
readln(p);
for i:=1 to p do
begin
write('Cuantas habitaciones hay en el piso ',i,' : ');
readln(a);
for j:= 1 to a do
begin
n:=n+1;
write('La habitacion ',n,' Es simple o mixta? S/M: ');
readln(resp);
v[n].tipo:= resp;
v[n].piso:=i;
v[n].numero:=n;
v[n].estado:='L';
v[n].precio:=80;
v[n].mensaje:='No hay ningun mensaje ';
end;
end;
end;
begin
writeln ('Datos de ingreso:');
write('dia: ');
readln(dia);
write('mes: ');
readln(mes);
write('Anio: ');
readln(anio);
end;
write('Ingrese cantidad de dias que se va a alojar: ');
readln(c);
write('Es temporada? S/N: ');
readln(resp);
If (resp='S') then
begin
if (tipo='S') then
precio:= (precio + 55*precio/100)*c
else
precio:= (precio + 30*precio*c/100)*c;
end
else
precio:=precio * c;
estado:='O';
end
else
BEGIN
writeln('HABITACION OCUPADA');
readln;
end;
end;
Procedure MostrarOcupado(v:vector);
var
i:integer;
begin
clrscr;
procedure MostrarDatos(v:vector);
var
c:integer;
begin
clrscr;
write('Ingrese El Nro de Habitacion que Desea Consultar: ');
readln(c);
with v[c] do
begin
with Dper do
begin
writeln('Nombre:',nombre);
writeln('Apellido:',apellido);
writeln('DNI:',DNI);
writeln('Telefono: ', tel);
end;
with Ingreso do
writeln('Fecha de Ingreso: ',dia,'/',mes,'/',anio);
writeln('Debe Pagar:',precio:5:2);
writeln('Mensaje: ', mensaje);
end;
readln;
end;
begin
cargarhotel(v,n);
repeat
clrscr;
writeln('_________________MENU________________');
program project1;
uses
crt;
const
max=1000;
type
Fechas=record
dia:Integer;
mes:Integer;
anio:Integer;
end;
Datos=record
Nombre:string;
apellido:string;
dni:String;
tel:string;
End;
Habitacion=record
Numero:integer;
piso:integer;
Tipo:Char;
Estado:Char;
Dper:Datos;
ingreso:Fechas;
egreso:Fechas;
Mensaje:String;
precio:real;
end;
vector=array[1..max] of Habitacion;
Var
n,r:integer;
v:vector;
begin
n:=0;
write('Ingrese cantidad de pisos del hotel: ');
readln(p);
for i:=1 to p do
begin
write('Cuantas habitaciones hay en el piso ',i,' : ');
readln(a);
for j:= 1 to a do
begin
n:=n+1;
write('La habitacion ',n,' Es simple o mixta? S/M: ');
readln(resp);
v[n].tipo:= resp;
v[n].piso:=i;
v[n].numero:=n;
v[n].estado:='L';
v[n].precio:=80;
v[n].mensaje:='No hay ningun mensaje ';
end;
end;
end;
end;
with Ingreso do
begin
writeln ('Datos de ingreso:');
write('dia: ');
readln(dia);
write('mes: ');
readln(mes);
write('Anio: ');
readln(anio);
end;
write('Ingrese cantidad de dias que se va a alojar: ');
readln(c);
write('Es temporada? S/N: ');
readln(resp);
If (resp='S') then
begin
if (tipo='S') then
precio:= (precio + 55*precio/100)*c
else
precio:= (precio + 30*precio*c/100)*c;
end
else
precio:=precio * c;
estado:='O';
end
else
BEGIN
writeln('HABITACION OCUPADA');
readln;
end;
end;
Procedure MostrarOcupado(v:vector);
var
i:integer;
begin
clrscr;
write ('La Habitaciones ocupadas son: ' );
for i:=1 to n do
with v[i] do
if estado='O' then
write (i,', ');
writeln();
end;
procedure MostrarDatos(v:vector);
var
c:integer;
begin
clrscr;
write('Ingrese El Nro de Habitacion que Desea Consultar: ');
readln(c);
with v[c] do
begin
with Dper do
begin
writeln('Nombre:',nombre);
writeln('Apellido:',apellido);
writeln('DNI:',DNI);
writeln('Telefono: ', tel);
end;
with Ingreso do
writeln('Fecha de Ingreso: ',dia,'/',mes,'/',anio);
writeln('Debe Pagar:',precio:5:2);
writeln('Mensaje: ', mensaje);
end;
readln;
end;
begin
cargarhotel(v,n);
repeat
clrscr;
writeln('_________________MENU________________');
writeln('1.Mostrar Habitaciones Disponibles y ocupar una');
writeln('2.Mostrar datos del cliente de una habitacion');
writeln('3.Agregar un mensaje');
writeln('4.Salir');
write('Elija una Opcion: ');
readln(r);
case r of
1:MostrarLibre(v);
2:MostrarDatos(v);
3:Msj(v);
end;
until (r=4);
end.
vector=array[1..50] of integer;
var
vec:vector;
t, pri, ult: integer;
op:char;
procedure menu;
begin
writeln('############# MENU ###############');
writeln('1- CARGAR VECTOR ');
writeln('2- ORDENACION rapido');
writeln('3- MOSTRAR vector');
writeln('6- SALIR');
writeln('SU OPCION?');
end;
procedure cargar (var v:vector; var x:integer);
var
i:integer;
begin
writeln('Ingrese la cantidad numeros:');
readln(x);
for i:= 1 to x do
readln (v[i]);
end;
procedure mostrar (v:vector; x:integer);
var
i:integer;
begin
for i:= 1 to x do
writeln (v[i]);
readln;
end;
Procedure Swap(Var X, Y : char);
Var
Temp: char;
Begin
Temp:= X;
X:= Y;
Y:= Temp
End;
inc(i);
while v[j]> pivote do
dec(j);
if i<=j then
begin
aux:=v[i];
v[i]:=v[j];
v[j]:=aux;
inc(i);
dec(j);
end;
until i> j;
if primero< j then
Quick_Sort(primero,j,v);
if ultimo > i then
Quick_Sort(i,ultimo,v);
end;
begin
repeat
clrscr;
menu;
readln(op);
case op of
'1': cargar(vec,t);
'2': begin
pri:=1;
ult:=t;
Quick_Sort (pri, ult,vec);
end;
'3': mostrar (vec,t);
'6': writeln('fin');
end;
until op='6';
readln;
end.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++TP4-_ EJERC 9+++++++++++++++++++++++++++++++++
program albumes;
uses
crt;
type
tiempo=record
min:integer;
seg:integer;
end;
album=record
orden:integer;
tema:string;
duracion:tiempo;
oyentes:integer;
end;
var
v1,v2,v3:vector;
t1,t2,t3, op, pos: integer;
tem:string;
procedure menu;
begin
writeln('############# MENU ###############');
writeln('1- CARGAR ALBUM 1 ');
writeln('2- CARGAR ALBUM 2 ');
writeln('3- MOSTRAR ALBUM 1');
writeln('4- MOSTRAR ALBUM 2');
writeln('5- ORDENACION POR TEMA A1');
writeln('6- ORDENACION POR TEMA A2');
writeln('7- INTERCALAR LOS ALBUMES');
writeln('8- MOSTRAR ALBUM INTERCALADO');
write('Oyentes: ');
readln (oyentes);
end;
end;
var
i,j: integer;
pivote: string;
aux:album;
begin
i:=primero;
j:=ultimo;
pivote:=v[(primero+ ultimo) div 2].tema;
repeat
while v[i].tema< pivote do
inc(i);
while v[j].tema> pivote do
dec(j);
if i<=j then
begin
aux:=v[i];
v[i]:=v[j];
v[j]:=aux;
inc(i);
dec(j);
end;
until i> j;
if primero< j then
rapido(primero,j,v);
if ultimo > i then
rapido(i,ultimo,v);
end;
rapido(primero,j,v);
if ultimo > i then
rapido(i,ultimo,v);
end;
else
binaria:=central;
end;
if o>m then
for s:=p to n do
begin
z[k]:=y[s];
k:=k+1;
end
else {p>n}
for s:=o to m do
begin
z[k]:=x[s];
k:=k+1;
end;
q:=m+n;
end;
begin{principal}
repeat
clrscr;
menu;
readln(op);
case op of
1: cargar(v1,t1);
2: cargar(v2,t2);
3: mostrar(v1,t1,1);
4: mostrar(v2,t2,2);
5: rapido(1,t1, v1);
6: rapido(1,t2, v2);
7: mezcla(v1, v2, v3, t1, t2, t3);
8: mostrar(v3,t3,3);
9: begin
writeln('Ingrese el tema a buscar:');
readln(tem);
pos:=binaria(tem, v3, t3);
if pos=0 then
writeln('Tema Inexistente')
else
writeln('Posicion: ',pos );
readln;
end;
10:rapidoo(1,t1, v1);
11: writeln('FIN');
end;
until op=11;
readln;
end.
[/color]
********************************************************************************
************************
********************************************************************************
************************+ tp5_1;+[/size]
program tp5_1;
uses
crt;
Var
S,P,Q: String[80];
begin
S := 'Diego Maradona';
P:= ' ';
writeln('pos: ',Pos(P,S)+1 );
writeln('longitud s: ',Length(S)-1 );
readln;
Q:= Copy(S, Pos(P,S) + 1, Length(S) - Pos(P,S)) + P + Copy(S, 1, Pos(P,S) - 1);
Writeln(Q);
readln;
end.
********************************************************************************
************************
********************************************************************************
************************
TP 5 EJERCICIO 5
program project1;
uses crt;
type
vocales=set of char;
vector=array[1..100] of string;
procedure LetraMasRepetida(f:string;b:boolean);
var
aux:string;
i,j:integer;
a,gc:char;
acum,gv:real;
begin
if b then
begin
aux:=f;
while Pos(' ',aux)<>0 do
Delete(aux,Pos(' ',aux),1);
gv:=0;
while Length(aux)<>0 do
begin
acum:=0;
a:=aux[i];
for i:=1 to Length(aux) do
if a=aux[i] then
acum:=acum+1;
if gv<acum then
begin
gv:=acum;
gc:=a;
end;
while(Pos(a,aux)<>0) do
Delete(aux,Pos(a,aux),1);
end;
writeln('Letra mas repetida: ',gc);
writeln('Se repitio el ',gv/Length(f)*100:3:2,' % de veces');
readKey;
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure insertarFrase(var f:string;b:boolean);
var
aux,p1,p2:string;
begin
if b then
begin
writeln('Frase original: ',f);
write('Palabra 1: ');
readln(p1);
write('Palabra 2: ');
readln(p2);
if (pos(p1,f))<(pos(p2,f)) then
begin
writeln('Frase a insertar: ');
readln(aux);
aux:=Concat(' ',aux);
Insert(aux,f,pos(p1,f)+Length(p1));
end
else
begin
writeln('Frase a insertar: ');
readln(aux);
aux:=Concat(' ',aux);
Insert(aux,f,pos(p2,f)+Length(p2));
end;
writeln('Frase Nueva: ',f);
readKey;
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure sumaAritmetica(f:string;b:boolean);
var
aux:string;
sum,i,a,cod:integer;
begin
if b then
begin
aux:='';
sum:=0;
for i:=1 to Length(f) do
begin
if (f[i] in ['0'..'9']) then
aux:=Concat(aux,f[i]);
if (not(f[i] in ['0'..'9']))or(i=Length(f)) then
begin
Val(aux,a,cod);
if cod=0 then
sum:=sum+a;
aux:='';
end;
end;
writeln('La suma aritemetica de los caracteres numericos es: ',sum);
readKey;
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure convAMayusc(var f:string;b:boolean);
var
aux:string;
i,p:integer;
begin
if b then
begin
writeln('Frase original: ',f);
write('Palabra o frase a convertir: ');
readln(aux);
if Pos(aux,f)<>0 then
for i:=Pos(aux,f) to (Pos(aux,f)+Length(aux)) do
f[i]:=Upcase(f[i])
else
begin
writeln('Palabra inexistente');
readKey;
end;
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure cargarVector(var v:vector;cad:string;var n:integer);
var
aux:string;
i:integer;
begin
aux:='';
n:=1;
for i:=1 to Length(cad) do
begin
if (cad[i]<>' ') then
aux:=Concat(aux,cad[i]);
if (cad[i]=' ')or(i=Length(cad)) then
begin
v[n]:=aux;
aux:='';
inc(n);
end;
end;
end;
Procedure Swap(Var X, Y : string);
Var
Temp: string;
Begin
Temp:= X;
X:= Y;
Y:= Temp
End;
(*-------------------------- Q U I C K S O R T ---------------------*)
Procedure Partition(Var A : vector; First, Last : Integer);
Var
Right, Left : Integer;
V : string;
Begin
V := A[(First + Last) Div 2];
Right := First;
Left := Last;
Repeat
While (A[Right] < V) Do
Right := Right + 1;
While (A[Left] > V) Do
Left := Left - 1;
If (Right <= Left) Then
Begin
Swap(A[Right], A[Left]);
Right := Right + 1;
Left := Left - 1
End;
Until Right > Left;
If (First < Left) Then
Partition(A, First, Left);
If (Right < Last) Then
for i:=1 to n do
v[i]:='';
end;
procedure OrdenarMenorMayor(f:string;b:boolean);
var
palabras:vector;
cant:integer;
begin
if b then
begin
cargarVector(palabras,f,cant);
QuickSort(palabras,cant);
mostrarVector(palabras,cant);
vaciarVector(palabras,cant);
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
function ContarVoc(f:string):integer;
var
c:integer;
i:integer;
voc:vocales;
begin
c:=0;
voc:=['A','E','I','O','U','a','e','i','o','u'];
for i:=1 to Length(f) do
if (f[i] in voc) then
c:=c+1;
ContarVoc:=c;
end;
procedure CantVocales(f:string;b:boolean);
begin
if b then
begin
writeln('La frase tiene ',ContarVoc(f),' vocales');
readKey;
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure eliminarEspacios(var cad:string;b:boolean);
var
aux:string[2];
p,i:integer;
begin
if b then
begin
aux:=' ';
repeat
p:=Pos(aux,cad);
if p<>0 then
Delete(cad,p,1);
until pos(aux,cad)=0;
if cad[1]=' ' then
delete(cad,1,1);
if cad[Length(cad)]=' ' then
delete(cad,Length(cad),1);
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure submenu(var o:char);
begin
writeln('1.Mostrar de principio a fin');
writeln('2.Mostrar de fin a principio');
write('Elija opcion: ');
readln(o);
end;
procedure mosFP(f:string);
var
aux: string;
i:integer;
begin
aux:='';
for i:=Length(f) downto 1 do
aux:=Concat(aux,f[i]);
write(aux);
readKey;
end;
procedure mostrarFrase(cad:string;b:boolean);
var
o:char;
begin
if b then
begin
repeat
submenu(o);
case o of
'1':begin
write(cad);
readKey;
end;
'2':mosFP(cad);
else
writeln('Incorrecto');
delay(1200);
end;
until (o='1') or (o='2');
end
else
begin
writeln('Primero ingrse a opcion 1');
delay(1500);
end;
end;
procedure IngresarFrase(var cad:string;var b:boolean);
begin
if not b then
b:=true;
write('Frase: ');
readln(cad);
end;
procedure menu(var o:char);
begin
gotoxy(18,3);write('********************MENU********************');
gotoxy(19,5);write('1. Ingresar una frase');
gotoxy(19,6);write('2. Mostrar la frase');
gotoxy(19,7);write('3. Eliminar espacios dobles');
gotoxy(19,8);write('4. Mostrar cantidad de vocales');
gotoxy(19,9);write('5. Mostrar letra mas repetida');
'7':OrdenarMenorMayor(frase,band);
'8':sumaAritmetica(frase,band);
'9':insertarFrase(frase,band);
'0': writeln('ADIOS');
else
writeln('Opcion Incorrecta');
delay(1200);
end;
until op='0';
delay(1200);
end;
begin
Ejercicio5;
end.
PARA LOS QUE NECESITAN AYUDA PARA EL PARCIAL AQUI LES DEJO UN EJERCCIO ESPERO Q LES
SEA DE AYUDA
program HOTEL;
uses
crt;
const
max=1000;
type
Fechas=record
dia:Integer;
mes:Integer;
anio:Integer;
end;
Datos=record
cedula:integer;
apenom:string;
valor:real;
tasa:real;
fecpres:fechas;
End;
vector=array[1..max] of datos;
Var
n,r:integer;
v:vector;
writeln('Ingrese Cedula:');
readln(cedula);
writeln('Ingrese apellido y nombre:');
readln(apenom);
writeln('Ingrese valor del prestamo:');
readln(valor);
writeln('Ingrese tasa %:');
readln(tasa);
with fecpres do
begin
writeln('Ingrese dia:');
readln(dia);
writeln('Ingrese mes:');
readln(mes);
writeln('Ingrese anio:');
readln(anio);
end;
end;
end;
intere:=valor*(tasa/100)*(360-fecpres.dia/360)
end;
interes:=intere;
end;
begin
cargarhotel(v,n);
repeat
clrscr;
writeln('_________________MENU________________');
writeln('1.Mostrar Habitaciones Disponibles y ocupar una');
writeln('2.Mostrar datos del cliente de una habitacion');
writeln('3.Agregar un mensaje');
writeln('4.Salir');
write('Elija una Opcion: ');
readln(r);
case r of
1:MostrarLibre(v);
2:MostrarDatos(v);
3:Msj(v);
end;
until (r=4);
end.
bueno aqui subo estos ejercicios que me tocaron en el primer parcial cabe aclarar que no tengo los
enunciados pero supongo que uds podran deducirlos si analizan el algoritmo bueno les dejo el
punto 1 del primer parcial 2011
1)
program Parcial;
uses crt;
var
fichero: text;
linea: string;
opc:integer;
cant:integer;
WRITELN('el promedio es 'prom/cant);
BEGIN
cnota:=0;
prom:=0;
while not eof (f)do
begin
writeln ('alumno':20'nota');
readln(F,l);
alumno:=copy(linea,1,20);
cnota:=copy(linea, 21, 3);
val(cnota,nota,Codigo);
if Codigo = 0 then
if nota >= 5 then
writeln(alumno:20,'aprobado');
Cant:= Cant + 1;
prom:=prom+nota;
else
writeln(alumno:20 ,'desaaprobado');
cant:=Cant+1 ;
prom:=prom+nota;
END;
end;
procedure salir
begin
writeln('gracias por utilizar esta aplicacion ');
writeln('presione una tecla para salir');
readkey;
end
begin
menu(OPC);
repeat
menu(opc);
CASE OPC OF
1:MOSTRARA(fichero,linea);
2ALIR ;
END;
until OPC=3;
end.