trankhanh47

SWAPPING TWO ROWS OF AN ARRAY

Dec 7th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.52 KB | None | 0 0
  1. program doi_dong;
  2. uses crt;
  3. var F1,F2:text;A:array[1..100,1..100] of integer;
  4.    i,j,m,n,x,y,C:integer;
  5. begin
  6.  clrscr;
  7.  Assign(F1,'game.inp'); Reset(F1);
  8.  Read(F1,m);Read(F1,n);
  9.  For i:=1 to m do
  10.    Begin
  11.     Readln(F1);
  12.     For j:=1 to  n do
  13.      Read(F1,A[i,j]);    end;
  14.  Close(f1);
  15.  Write('Nhap 2 dong muon chuyen doi: ');readln(x,y);
  16.  For j:=1 to n do
  17.   begin
  18.    C:=A[x,j]; A[x,j]:=A[y,j]; A[y,j]:=C; end;
  19.  For i:=1 to m do
  20.   begin
  21.   writeln;
  22.   For j:=1 to n do
  23.     Write(A[i,j]:5);
  24.   end;
  25.   readln
  26.   end.
Advertisement
Add Comment
Please, Sign In to add comment