Pascal/Turbo Pascal - AYUDA!!! Progamacion Pascal

 
Vista:

AYUDA!!! Progamacion Pascal

Publicado por APhil (1 intervención) el 05/06/2011 23:08:09
Hola, necesito hacer 2 programas en pascal:

Uno en el que de acuerdo al MES de nacimiento de una persona le escriba su nombre y su signo zodiacal

Y el segundo consta de un programa interactivo que permita al usuario intentar hasta 4 veces el teclear la capital de estado de sonora (hermosillo) Que señale el numero de intentos realizados y si la respuesta esta bien que mande el mensaje CORRECTO de lo contrario que diga INCORRECTO. Si el usuario despues de 4 intentos no da la respuesta correcta, que el programa le de la respuesta.
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

AYUDA!!! Progamacion Pascal

Publicado por ramon (2158 intervenciones) el 08/06/2011 17:14:53
{primer programa después el otro}


program signozd;
uses
crt, dos;
const
meszodiaco : array[1..12] of string[11] = (
'CAPRICORNIO','ACUARIO','PISCIS','ARIES','TAURO',
'GEMINIS','CANCER','LEO','VIRGO','LIBRA','ESCORPIO',
'SAGITARIO');

type
string10 = string[10];
string11 = string[11];


var
nombre : string[30];
i : integer;
mes : string10;
diafe, mesfe : string[2];
anofe : string[4];
salir : char;
y, m, d, dow : Word;
edad, anosna, error : integer;

function zodiaco(mes : string10) : string11;
var
m, d : string[2];
ed, er, ms, di : integer;
begin
zodiaco := ' ';
m := copy(mes,4,5);
d := copy(mes,1,2);
val(d,di,er);
val(m,ms,ed);
if ((ms = 12) and (di in[22..31])) or ((ms = 1) and (di in[1..20])) then
zodiaco := meszodiaco[1];
if ((ms = 1) and (di in[21..31])) or ((ms = 2) and (di in[1..19])) then
zodiaco := meszodiaco[2];
if ((ms = 2) and (di in[20..29])) or ((ms = 3) and (di in[1..20])) then
zodiaco := meszodiaco[3];
if ((ms = 3) and (di in[21..31])) or ((ms = 4) and (di in[1..20])) then
zodiaco := meszodiaco[4];
if ((ms = 4) and (di in[21..30])) or ((ms = 5) and (di in[1..21])) then
zodiaco := meszodiaco[5];
if ((ms = 5) and (di in[22..31])) or ((ms = 6) and (di in[1..21])) then
zodiaco := meszodiaco[6];
if ((ms = 6) and (di in[22..30])) or ((ms = 7) and (di in[1..23])) then
zodiaco := meszodiaco[7];
if ((ms = 7) and (di in[24..31])) or ((ms = 8) and (di in[1..23])) then
zodiaco := meszodiaco[8];
if ((ms = 8) and (di in[24..31])) or ((ms = 9) and (di in[1..23])) then
zodiaco := meszodiaco[9];
if ((ms = 9) and (di in[24..30])) or ((ms = 10) and (di in[1..23])) then
zodiaco := meszodiaco[10];
if ((ms = 10) and (di in[24..31])) or ((ms = 11) and (di in[1..22])) then
zodiaco := meszodiaco[11];
if ((ms = 11) and (di in[23..30])) or ((ms = 12) and (di in[1..21])) then
zodiaco := meszodiaco[12];
end;

procedure entradas;
var
tec : char;
termi : boolean;
cd1, cm1, ca1 : integer;
dia, mese : string[2];
ano : string[4];
er1, er2, er3 : integer;
begin
clrscr;
gotoxy(10,3);write('Entre Nombre : ');
gotoxy(25,3);read(nombre);
gotoxy(10,4);write('Entre Fecha Nacimiento = Dia/Mes/A¤o : / / ');
gotoxy(10,5);write('Formato = 01/03/2011');
cd1 := 1;
termi := false;
gotoxy(49,4);
repeat
tec := readkey;
if tec in[#48..#57] then
begin
dia[cd1] := tec;
dia[0] := chr(cd1);
gotoxy(48 + cd1,4);write(dia[cd1]);
cd1 := cd1 + 1;
end;
until cd1 > 2;

cm1 := 1;
gotoxy(52,4);
repeat
tec := readkey;
if tec in[#48..#57] then
begin
mese[cm1] := tec;
mese[0] := chr(cm1);
gotoxy(51 + cm1,4);write(mese[cm1]);
cm1 := cm1 + 1;
end;
until cm1 > 2;

ca1 := 1;
gotoxy(55,4);
repeat
tec := readkey;
if tec in[#48..#57] then
begin
ano[ca1] := tec;
ano[0] := chr(ca1);
gotoxy(54 + ca1,4);write(ano[ca1]);
ca1 := ca1 + 1;
end;
until ca1 > 4;
diafe := copy(dia,1,2);
mesfe := copy(mese,1,2);
anofe := copy(ano,1,4);
end;




begin
clrscr;
textcolor(15);
GetDate(y,m,d,dow);
entradas;
clrscr;
writeln('Tu Nombre Es : ',nombre);
writeln('Tu Signo Del Zodiaco Es : ',zodiaco(diafe + '/' + mesfe + '/' + anofe));
val(anofe,anosna,error);
edad := y - anosna;
writeln('Tu Edad Es De : ',edad,' A¤os');
writeln('**** Pulsa [ ENTER ] Para Finalizar ****');
repeat
salir := readkey;
until salir = #13;
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

AYUDA!!! Progamacion Pascal

Publicado por ramon (2158 intervenciones) el 08/06/2011 18:47:58
{Segundo programa espero se sirvan]

program capitales;
uses
crt;
type
regdatos = record {Registros de datos para Estados y Capitales}
Estado : string[30];
capital : string[30];
end; {Se convertiria en un archivo de datos para el}
{programa}

string30 = string[30];


const
{seria el contegido del registro como Ejemplo en canstante}
datos : array[1..2] of string[30] = (
'Estado de Sonora','Hermosillo');


var
freg : file of regdatos;
capitalent : string[30];
estadoent : string[30];


function texto(xt, yt : integer; titu : string) : string30;
var
tecla : char;
i : integer;
dato : string[30];
begin
texto := ' ';
i := 1;
fillchar(dato,31,' ');
dato[0] := chr(30);
gotoxy(xt,yt);write(titu,' : ');
gotoxy(xt + length(titu) + 3,yt);
repeat
tecla := readkey;
if upcase(tecla) in[#65..#90,#32] then
begin
dato[i] := upcase(tecla);
dato[0] := chr(i);
gotoxy((xt + length(titu) + 2) + i,yt);write(dato[i]);
i := i + 1;
if i > 30 then
begin
sound(289);
delay(100);
nosound;
i := i - 1;
end;
end;
if tecla = #8 then
begin
i := i - 1;
if i < 1 then
begin
sound(189);
delay(100);
nosound;
i := i + 1;
end;
dato[i] := ' ';
dato[0] := chr(i);
gotoxy((xt + length(titu) + 2) + i,yt);write(dato[i]);
end;
until (tecla = #13) or (tecla = #27);
if tecla = #13 then
begin
texto := copy(dato,1,i - 1);
gotoxy(xt,yt);clreol;
end;
end;

procedure capital(elestado : string30);
var
capitalent : string[30];
i, cont : integer;
cierto : boolean;
begin
cierto := false;
cont := 1;
capitalent := ' ';
for i := 1 to length(datos[2]) do
begin
capitalent[i] := upcase(datos[2][i]);
capitalent[0] := chr(i);
end;
repeat
if texto(10,3,'La Capital de ' + datos[1] + ' Es ') = capitalent then
begin
cierto := true;
end
else
begin
gotoxy(2,2);write('Prueve DE Nuevo Intentos : ',cont);
cont := cont + 1;
end;
until (cierto = true) or (cont > 4);
if cierto = true then
begin
clrscr;
textcolor(15);
writeln('CORRECTO');
writeln('La Capital de ' + datos[1] + ' Es ',capitalent);
writeln('Intentos Invertidos = ',cont);
end
else
begin
clrscr;
textcolor(15);
writeln('INCORRECTO');
writeln('Intentos Invertidos = ',cont);
writeln('La Capital de ' + datos[1] + ' Es ',datos[2]);
end;
end;



begin
clrscr;
capital(datos[1]);
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