09.05.2013 Views

Algoritmos y Programación en Pascal

Algoritmos y Programación en Pascal

Algoritmos y Programación en Pascal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

278 Capítulo 13. Registros<br />

type...<br />

tNombre = array[1..50] of char;<br />

tDNI = array[1..8] of ‘0’..’9’;<br />

tPais = array[1..20] of char;<br />

tPasaporte = array[1..15] of ‘0’..’9’;<br />

tFicha = record<br />

nombre: tNombre;<br />

fechaNac: tFecha;<br />

nota: tCalificaciones;<br />

case espannol : boolean of<br />

True :<br />

(dni : tDNI;<br />

False :<br />

(pais : tPais;<br />

pasaporte : tPasaporte<br />

<strong>en</strong>d; {tFicha}<br />

Con la definición anterior, el procedimi<strong>en</strong>to LeerFicha queda como sigue:<br />

procedure LeerFicha(var unAlumno: tFicha);<br />

{Efecto: lee del input el cont<strong>en</strong>ido del registro unAlumno}<br />

var<br />

c: char;<br />

begin<br />

with unAlumno do begin<br />

Write(’Introduce el nombre del alumno:’);<br />

ReadLn(nombre);<br />

with fechaNac do begin<br />

Write(’Día de nacimi<strong>en</strong>to: ’);<br />

ReadLn(dia);<br />

Write(’Mes de nacimi<strong>en</strong>to: ’);<br />

LeerMes(mes);<br />

Write(’A~no de nacimi<strong>en</strong>to: ’);<br />

ReadLn(anno)<br />

<strong>en</strong>d; {with fechaNac}<br />

Write(’Calificacion: ’);<br />

LeerNota(nota);<br />

repeat<br />

Write(’¿Es ’,nombre,’ espa~nol? (S/N)’);<br />

ReadLn(c)<br />

until c in [’s’,’S’,’n’,’N’];<br />

case c of<br />

’s’,’S’ :<br />

begin {el alumno es espa~nol}<br />

espannol:= True;<br />

Write(’DNI: ’);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!