Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. program forloop;
  2. uses crt;
  3. var a:array[1..10]of byte;
  4. temp:byte;
  5. i,k:byte;
  6. begin
  7. clrscr;
  8. (*fill the array with random numbers*)
  9. randomize;
  10. for i:=1 to 10 do begin
  11. a[i]:=random(100)+1;
  12. end;
  13. (*write the result to the screen*)
  14. writeln('first run: ');
  15. for i:=1 to 10 do begin
  16. write(a[i],' , ');
  17. end;
  18. writeln;
  19. (*short the numbers of the array a*)
  20. for i:=1 to 9 do begin
  21. for k:=i+1 to 10 do begin
  22. if a[i] > a[k] then begin
  23. temp:=a[i];
  24. a[i]:=a[k];
  25. a[k]:=temp;
  26. end;
  27. end;
  28. end;
  29. writeln;
  30. writeln;
  31. writeln('shorted results: ');
  32. (*write the result to the screen*)
  33. for i:=1 to 10 do begin
  34. write(a[i],',');
  35. end;
  36. writeln;
  37. (*press any key to quit*)
  38. while not keypressed do continue;
  39. end.
  40. (*created by FlamingClaw 2010.02.04.*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement