Advertisement
kanciastopantalones

Untitled

Nov 30th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 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.  
  10. readln(ilosc);
  11. if ilosc <=0 then
  12. begin
  13. repeat
  14. writeln('podaj DODATNIA wartosc dla ciagu');
  15. readln(ilosc);
  16. until ilosc>0;
  17. end;
  18.  
  19.  
  20. for i:=1 to ilosc do
  21. begin
  22. write('Podaj ', i, ' element ciagu: ');
  23. readln(tab[i]);
  24. end;
  25.  
  26.  
  27.  
  28. writeln;
  29. write('Ciag nieposortowany: ');
  30. for i:=1 to ilosc do
  31. write(tab[i], ' ');
  32.  
  33.  
  34.  
  35. writeln;writeln;
  36.  
  37.  
  38.  
  39. for i:=1 to ilosc-1 do
  40. begin
  41. write( i, ' wykonanie petli: ');
  42. for j:=1 to ilosc-1 do
  43. begin
  44. if tab[j]>tab[j+1] then
  45. begin
  46. pom:=tab[j];
  47. tab[j]:=tab[j+1];
  48. tab[j+1]:=pom;
  49. end;
  50. write(tab[j], ' ');
  51. end;
  52. write(tab[j+1]);
  53. writeln;
  54. end;
  55.  
  56.  
  57.  
  58. writeln;
  59. writeln;
  60. write('Ciag posortowany: ');
  61. for i:=1 to ilosc do
  62. write(tab[i], ' ');
  63.  
  64.  
  65.  
  66.  
  67. readln;
  68. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement