Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program forloop;
- uses crt;
- var a:array[1..10]of byte;
- temp:byte;
- i,k:byte;
- begin
- clrscr;
- (*fill the array with random numbers*)
- randomize;
- for i:=1 to 10 do begin
- a[i]:=random(100)+1;
- end;
- (*write the result to the screen*)
- writeln('first run: ');
- for i:=1 to 10 do begin
- write(a[i],' , ');
- end;
- writeln;
- (*short the numbers of the array a*)
- for i:=1 to 9 do begin
- for k:=i+1 to 10 do begin
- if a[i] > a[k] then begin
- temp:=a[i];
- a[i]:=a[k];
- a[k]:=temp;
- end;
- end;
- end;
- writeln;
- writeln;
- writeln('shorted results: ');
- (*write the result to the screen*)
- for i:=1 to 10 do begin
- write(a[i],',');
- end;
- writeln;
- (*press any key to quit*)
- while not keypressed do continue;
- end.
- (*created by FlamingClaw 2010.02.04.*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement