Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { paulogp }
- { mac os 7 }
- program Ada19p;
- uses
- MemTypes, QuickDraw, OSIntf;
- const
- MAX = 100;
- var
- k, l: Integer;
- fim: string;
- function amigos(a, b: Integer): Boolean;
- var
- I, j, n, soman, somam: integer;
- begin
- soman:= 0;
- somam:= 0;
- for I:= 1 to a - 1 do
- if (a mod I) = 0 then soman:= soman + I;
- for j:= 1 to b - 1 do
- if (b mod j) = 0 then somam:= somam + j;
- if (somam = a) and (soman = b) then amigos:= true else amigos:= false;
- end;
- begin
- repeat
- clearscreen;
- gotoxy(33, 2);
- writeln('Programa: Números Amigos!');
- gotoxy(33, 3);
- writeln('~~~~~~~~~~~~~~~~~');
- gotoxy(36, 4);
- writeln('Paulo G.P.');
- writeln;
- writeln('Programa iniciado!');
- writeln('Procura no intervalo [0 ,', MAX, '].');
- writeln;
- for k:= 2 to MAX do
- begin
- if k = MAX / 2 then
- begin
- writeln;
- writeln('Meio da contagem!');
- writeln;
- end;
- for l:= 2 to MAX do
- if amigos(k, l) then writeln(' São amigos: ', k, ' & ', l);
- end;
- writeln;
- writeln('Terminado!');
- writeln;
- write('Repetir (s/n): ');
- readln(fim);
- uprstring(fim, true);
- until fim = 'N';
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement