Advertisement
kanciastopantalones

Untitled

Dec 6th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. program sortowaniebabelkowe;
  2.  
  3. uses
  4. crt;
  5.  
  6. var
  7. tab: array[1..100] of integer;
  8. i, j, ilosc, pom: integer;
  9. begin
  10. clrscr;
  11. Write('Z ilu elementow ma skladac sie ciag liczb: ');
  12.  
  13. readln(ilosc);
  14. if ilosc <= 0 then
  15. begin
  16. repeat
  17. writeln('podaj DODATNIA wartosc dla ciagu');
  18. readln(ilosc);
  19. until ilosc > 0;
  20. end;
  21.  
  22. for i := 1 to ilosc do
  23. begin
  24. Write('Podaj ', i, ' element ciagu: ');
  25. readln(tab[i]);
  26. end;
  27.  
  28. writeln;
  29. Write('Ciag nieposortowany: ');
  30. for i := 1 to ilosc do
  31. Write(tab[i], ' ');
  32.  
  33. writeln;
  34. writeln;
  35.  
  36. for i := 1 to ilosc - 1 do
  37. begin
  38. writeln;writeln;
  39. Write(i, ' wykonanie petli: ');
  40.  
  41. for j := 1 to ilosc - 1 do
  42. begin
  43. writeln;
  44. for pom :=1 to ilosc do begin
  45. if pom = j then write('(',tab[pom],' ')
  46. else if pom = j+1 then write(tab[pom], ') ')
  47. else write(tab[pom], ' ');
  48. end;
  49. //writeln;
  50. if tab[j] > tab[j + 1] then
  51. begin
  52. pom := tab[j];
  53. tab[j] := tab[j + 1];
  54. tab[j + 1] := pom;
  55. end;
  56. //Write(tab[j], ' ');
  57. end;
  58. writeln;
  59. for pom :=1 to ilosc do begin
  60. write(tab[pom], ' ');
  61. end;
  62. //Write(tab[j + 1]);
  63. //writeln;
  64. end;
  65.  
  66. writeln;
  67. writeln;
  68. Write('Ciag posortowany: ');
  69. for i := 1 to ilosc do
  70. Write(tab[i], ' ');
  71.  
  72. readln;
  73. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement