-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject1.pas
46 lines (40 loc) · 951 Bytes
/
project1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
program project1;
uses
classes, sysutils,StrUtils;
var i, j,numero, erro:longint;
arquivo: textfile;
lista: array of longint;
linha:string;
caracter:char;
maior, nummaior:longint;
begin
i:=0;
Assign(arquivo,'entrada.txt');
reset (arquivo);
while not eof(arquivo) do
begin
setlength (lista,i+1);
readln(arquivo,linha );
val (linha, numero, erro);
if erro=0 then
begin
lista[i]:=lista[i] + numero;
end
else
begin
if lista[i] <> 0 then
i:=i+1;
end;
end;
maior:=0;
for j:=0 to length(lista)-1 do
begin
if nummaior<lista[j] then
begin
nummaior:= lista[j];
maior:=j;
end;
writeln ('Elfo numero ',j+1,' possui ',lista[j]);
end;
writeln ('O maior ‚ o Elfo ',maior+1,' que possui ',nummaior);
end.