Generate 200 numbers and switch 2 number in array

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Category: Homework in Pascal

Author: Juraj Pupák
Program: Vymenaho.pas
File exe: Vymenaho.exe

Generate 200 numbers and switch 2 number in array.
{ VYMENAHO.PAS                                                      }
{ Vygeneruje pole 200 cisel a u dvoch cisel vymeni pozicie.         }
{                                                                   }
{ Author: Juraj Pupak                                               }
{ Date  : 27.10.2006                           http://www.trsek.com }
 
program VymenaHodnotPola;
uses crt;
  var
    index,temp,a,j : integer;
    Pole : array [1..200] of integer;
 
begin
  clrscr;
  writeln('Zadaj pozicie na ktorych sa maju hodnoty vymenit. Mozes zadat pozicie 1 az 200');
  readln(a);
  readln(j);
  For index := 1 To 200 Do
    begin
      Pole[index] := Random(200);
    end;
  temp := Pole[j];
  Pole[j] := Pole[a];
  Pole[a] := temp;
  writeln('Na pozicii ',j,' je hodnota ',Pole[j],' na pozicii ',a,' je hodnota ',Pole[a],'.');
  readln;
end.