Advertisement
paulogp

Algoritmo de Euclides

Aug 7th, 2011
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.70 KB | None | 0 0
  1. { paulogp }
  2. { mac os 7 }
  3. program Ada03p;
  4.  
  5. uses
  6.     MemTypes, QuickDraw, OSIntf;
  7.  
  8. var
  9.     a, b, x, y, resto: integer;
  10.     fim: string;
  11.  
  12. begin
  13.     repeat
  14.         clearscreen;
  15.         writeln('Programa: Cálculo do Maior Divisor Comum.');
  16.         writeln('          Algoritmo de Euclides.');
  17.         writeln;
  18.         write('Introduza o valor de A: ');
  19.         readln(a);
  20.         writeln;
  21.         write('Introduza o valor de B: ');
  22.         readln(b);
  23.         x:= a;
  24.         y:= b;
  25.         while b <> 0 do
  26.         begin
  27.             resto:= a mod b;
  28.             a:= b;
  29.             b:= resto;
  30.         end;
  31.  
  32.         writeln;
  33.         writeln('O Máximo Divisor Comum de ', x, ' e ', y, ' é ', a, '.');
  34.         writeln;
  35.         writeln;
  36.         write('Repetir programa (S/N): ');
  37.         readln(fim);
  38.         uprstring(fim, true);
  39.     until fim = 'N';
  40. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement