Pascal/Turbo Pascal - AYUDENME..!!

 
Vista:

AYUDENME..!!

Publicado por dani gonzalez (9 intervenciones) el 19/01/2012 02:40:32
PLEASE..... Necesito q me ayuden a hacr un programa de un concesionario de autos.. q me permita vender y recibir autos y mostrar el estado del concesionario...!!
hay q usar arreglos,funciones y procedimientos..!!!
HELP ME!!!!!!!!!!!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

AYUDENME..!!

Publicado por dani gonzalez (9 intervenciones) el 19/01/2012 03:07:13
OLVIDE MENCIONAR Q SE UTILIZAN REGISTROS!!
EL REGISTRO ES SOBRE LA INFORMACION DEL AUTO:
auto=record
marca:
modelo
color
cilindrada
precio
end

Se debe ubicar el auto por modelo...!! y vender el 1ro q haya de la lista!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

AYUDENME..!!

Publicado por ramon (2158 intervenciones) el 20/01/2012 17:25:39
{A ver vamos bien por este camino}

program autosv;
uses
crt;
type
auto = record
marca : string[40];
modelo : string[20];
color : string[20];
cilindrada : string[20];
precio : real;
end;

almacen = record
coches : array[1..200] of auto;
sto : integer;
end;

const
archivo : string = 'c:\tp\autos.dat';

var
veiculos : almacen;
f : file of auto;
datau : auto;
tecla : char;
cont : longint;


function existe_archivo : boolean;
begin
existe_archivo := false;
assign(f,archivo);
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
existe_archivo := false;
end
else
begin
existe_archivo := true;
close(f);
end;
end;

function readln10(xr, yr : integer; tipo : char) : string;
var
i : integer;
dato : string[40];
lon : integer;
begin
readln10 := ' ';
fillchar(dato,41,' ');
dato[0] := chr(40);
gotoxy(xr,yr);
i := 1;
if tipo in['t','T'] then
lon := 40;
if tipo in['n','N'] then
lon := 12;
repeat
tecla := readkey;
if (tipo = 't') or (tipo = 'T') then
begin
if tecla in[#48..#125,#154,#165,#32] then
begin
dato[i] := tecla;
dato[0] := chr(i);
gotoxy((xr - 1) + i,yr);write(dato[i]);
i := i + 1;
if i > lon then
i := lon;
end;
end;
if (tipo = 'n') or (tipo = 'N') then
begin
if tecla in[#48..#57,#44,#46] then
begin
if tecla = #44 then
tecla := #46;
dato[i] := tecla;
dato[0] := chr(i);
gotoxy((xr - 1) + i,yr);write(dato[i]);
i := i + 1;
if i > lon then
i := lon;
end;
end;
if tecla = #8 then
begin
i := i - 1;
if i < 1 then
i := 1;
dato[i] := ' ';
dato[0] := chr(i);
gotoxy((xr - 1) + i,yr);write(dato[i]);
end;
until tecla = #13;
if i > 1 then
readln10 := copy(dato,1,length(dato));
end;

procedure entrada_coches;
var
prec : string[12];
err : integer;
begin
clrscr;
gotoxy(10,2);write('**** Entradas Veiculos ****');
gotoxy(10,4);write('Marca : ');
gotoxy(10,5);write('Modelo : ');
gotoxy(10,6);write('Color : ');
gotoxy(6,7);write('cilindrada : ');
gotoxy(10,8);write('Precio : ');
datau.marca := readln10(19,4,'t');
datau.modelo := readln10(19,5,'t');
datau.color := readln10(19,6,'t');
datau.cilindrada := readln10(19,7,'t');
prec := readln10(19,8,'n');
val(prec,datau.precio,err);
if err <> 0 then
begin
delete(prec,err,1);
val(prec,datau.precio,err);
end;
end;

procedure inicio_archivo;
var
posicion : longint;
pul : char;
begin
if existe_archivo = true then
begin
assign(f,archivo);
reset(f);
posicion := filesize(f);
end
else
begin
assign(f,archivo);
rewrite(f);
posicion := 0;
end;
repeat
entrada_coches;
seek(f,posicion);
write(f,datau);
posicion := posicion + 1;
gotoxy(10,12);write('Desea Entrar Mas Autos [S/N]');
pul := readkey;
clrscr;
until pul in['n','N'];
close(f);
end;

procedure ordena_por_modelo;
var
id : longint;
r, d : integer;
temp : auto;
f1 : file of auto;
begin
if existe_archivo = true then
begin
assign(f,archivo);
reset(f);
cont := filesize(f) - 1;
if cont > 200 then
cont := 200;
for id := 0 to cont do
begin
seek(f,id);
read(f,datau);
veiculos.coches[id + 1] := datau;
end;
close(f);
for r := 1 to cont - 1 do
for d := cont downto r do
begin
if veiculos.coches[r].modelo > veiculos.coches[d].modelo then
begin
temp := veiculos.coches[r];
veiculos.coches[r] := veiculos.coches[d];
veiculos.coches[d] := temp;
end;
end;
end;
assign(f1,'c:\tp\temporal.tpl');
rewrite(f1);
for id := 0 to cont - 1 do
begin
seek(f1,id);
write(f1,veiculos.coches[id]);
end;
close(f1);
erase(f);
rename(f1,archivo);
end;

procedure mostrar_el_estado;
begin

end;


begin
clrscr;
inicio_archivo;
ordena_por_modelo;
mostrar_el_estado;
readln;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar