Created
June 17, 2018 12:31
-
-
Save matipan/3f165c58ade39bcdaaae3d3c023714dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program ej1; | |
const | |
valoralto = 99999; | |
type | |
votos = array [0..4] of integer; | |
partido = record | |
codigo : integer; | |
nombre : string[20]; | |
codLocal : integer; | |
nombreLocal : string[20]; | |
nroMesa : integer; | |
votos : votos; | |
end; | |
maestro = file of partido; | |
procedure leer(var m : maestro; var p : partido); | |
begin | |
if not eof(m) then | |
read(m, p) | |
else | |
p.codigo := valoralto; | |
end; | |
procedure resetArray(var i : votos); | |
var | |
j : integer; | |
begin | |
for j := 0 to 4 do | |
i[j] := 0; | |
end; | |
procedure contar(var m : maestro); | |
var | |
pactual, lactual, i : integer; | |
p : partido; | |
cuenta, total : votos; | |
begin | |
resetArray(total); | |
leer(m, p); | |
while(p.codigo <> valoralto) do begin | |
pactual := p.codigo; | |
writeln('Nombre de partido:', p.nombre); | |
while(p.codigo = pactual) do begin | |
resetArray(cuenta); | |
lactual := p.codLocal; | |
writeln('Nombre de localidad: ', p.nombreLocal); | |
while(p.codLocal = lactual) do begin | |
for i := 0 to 4 do | |
cuenta[i] := cuenta[i] + p.votos[i]; | |
leer(m, p); | |
end; | |
writeln('Total votos de localidad ', lactual, ': '); | |
writeln('Politicos 1 Politicos 2 Politicos 3 Politicos 4 Politicos 5'); | |
writeln(cuenta[0], cuenta[1], cuenta[2], cuenta[3], cuenta[4]); | |
for i := 0 to 4 do | |
total[i] := total[i] + cuenta[i]; | |
end; | |
end; | |
writeln('TOTAL GRAL ', total[0], total[1], total[2], total[3], total[4]); | |
end; | |
var | |
m : maestro; | |
begin | |
assign(m, 'maestro.dat'); | |
reset(m); | |
contar(m); | |
close(m); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment