Advertisement
trankhanh47

bangso

Oct 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.84 KB | None | 0 0
  1. //https://www.facebook.com/groups/thegioilaptrinh/permalink/1376965755772113/?comment_id=1377120149090007&reply_comment_id=1377302102405145&notif_id=1539840327155378&notif_t=group_comment
  2. uses crt;
  3.  
  4. var a:array[1..100,1..100] of longint;
  5. n,i,j:longint;
  6.  
  7. procedure print;
  8. var i,j:longint;
  9. begin
  10.         for i:=1 to n do
  11.                 begin
  12.                 writeln;
  13.                 for j:=1 to n do write(a[i,j],' ');
  14.                 end;
  15.  end;
  16.  
  17.         begin
  18.         readln(n);
  19.         for i:=1 to n do
  20.         for j:=1 to n do
  21.                 begin
  22.         if (i*j<=2*n) then a[i,j]:=i*j;
  23.         if (i*j>2*n) and ((i*(j-1))<=2*n) then a[i,j]:=2;
  24.         if (i=n) and (i*j>2*n) and (i*(j-1)<=2*n) then a[i,j]:=4;
  25.         if (i*j>2*n) and ((i*(j-1))>2*n) then a[i,j]:=a[i,j-1]+2;
  26.                 end;
  27.         print;
  28. readln
  29. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement