# Soluções da aula prática 10

1.
PROGRAM Orden;

CONST N = 10;

Var ra: array[1..N] of real;
i: integer;
changed: boolean;
temp: real;

begin
(* pedir 10 numeros: *)
for i := 1 to N do
begin
WriteLn('Numero ',i,':');
end;
changed := TRUE;
(* continue ate nao houve mais mudancas: *)
while changed do
begin
changed := FALSE;
for i := 1 to N-1 do
(* se ra[i] maior que ra[i+1] troca os dois *)
(* e asinala que houve mudanca: *)
if ra[i]>ra[i+1] then
begin
temp := ra[i];
ra[i] := ra[i+1];
ra[i+1] := temp;
changed := TRUE;
end;
end;
for i := 1 to N do
Writeln(i,'  ',ra[i]:0:1);
end.

2.
PROGRAM Recs;

type rec =
record
numero: integer;
div3: boolean;
end;
Var ra: array[1..100] of rec;
i: integer;
totdiv3: integer;

begin
for i := 1 to 100 do
ra[i].numero := Random(101)+14;
for i := 1 to 100 do
if ((ra[i].numero MOD 3) = 0) then
ra[i].div3 := TRUE
else
ra[i].div3 := FALSE;
totdiv3 := 0;
for i := 1 to 100 do
if (ra[i].div3=TRUE)
then totdiv3 := totdiv3+1;
WriteLn(totdiv3);
end.

3.
PROGRAM Recs;

type rec =
record
nome: string;
numero: longint;
end;
Var ra: array[1..100] of rec;
s: string;
i: integer;

PROCEDURE Initialize;
begin
ra[1].nome := 'Alex';
ra[1].numero := 289123456;
ra[2].nome := 'Sandra';
ra[2].numero := 289234567;
ra[3].nome := 'Joao';
ra[3].numero := 289345678;
ra[4].nome := 'Carla';
ra[4].numero := 289456789;
ra[5].nome := 'Hugo';
ra[5].numero := 289567890;
end;

begin
Initialize;
Writeln('Diz um nome:');