Advertisement
kanciastopantalones

Untitled

Nov 29th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. program sortowanie;
  2. uses crt;
  3. var
  4. tab:array[1..100] of integer;
  5. i,j,ilosc,pom:integer;
  6. begin
  7. clrscr;
  8. write('Z ilu elementow ma skladac sie ciag liczb: ');
  9. readln(ilosc);
  10.  
  11. for i:=1 to ilosc do
  12. begin
  13. write('Podaj ', i, ' element ciagu: ');
  14. readln(tab[i]);
  15. end;
  16.  
  17. writeln;
  18. write('Ciag nieposortowany: ');
  19. for i:=1 to ilosc do
  20. write(tab[i], ' ');
  21.  
  22. writeln;writeln;
  23.  
  24. for i:=1 to ilosc-1 do
  25. begin
  26. write( i, ' wykonanie petli: ');
  27. for j:=1 to ilosc-1 do
  28. begin
  29. if tab[j]>tab[j+1] then
  30. begin
  31. pom:=tab[j];
  32. tab[j]:=tab[j+1];
  33. tab[j+1]:=pom;
  34. end;
  35. write(tab[j], ' ');
  36. end;
  37. write(tab[j+1]);
  38. writeln;
  39. end;
  40.  
  41. writeln;
  42. writeln;
  43. write('Ciag posortowany: ');
  44. for i:=1 to ilosc do
  45. write(tab[i], ' ');
  46.  
  47.  
  48. readln;
  49. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement