Advertisement
paulogp

Matriz identidade

Aug 7th, 2011
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.75 KB | None | 0 0
  1. { paulogp }
  2. { mac os 7 }
  3. program Ada10p;
  4.  
  5. uses
  6.     MemTypes, QuickDraw, OSIntf;
  7.  
  8. var
  9.     i, j, n: integer;
  10.     fim: string;
  11.  
  12. begin
  13.     repeat
  14.         clearscreen;
  15.         writeln('Programa: Matriz Identidade!');
  16.         writeln('============================');
  17.         repeat
  18.             writeln;
  19.             write('Introduza um valor no intervalo ]0,20]: ');
  20.             readln(n);
  21.             writeln;
  22.             if (n <= 0) or (n > 20)  then write('Atenção!!!');
  23.         until (n > 0) and (n <= 20);
  24.         writeln;
  25.         for j:= 1 to n do
  26.         begin
  27.             for i:= 1 to n - 1 do
  28.             begin
  29.                 if (i = j)  then write('   1');
  30.                 write('   0');
  31.             end;
  32.             if (j = n) then write('   1') else writeln;
  33.         end;
  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