Guest User

Untitled

a guest
Jan 15th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. int ilosc, *tab;
  8.  
  9. void sortowanie_babelkowe(int tab[], int n)
  10. {
  11. for (int i = 0; i<n; i++)
  12. for (int j = 1; j<n - i; j++)
  13. if (tab[j - 1]>tab[j])
  14. swap(tab[j - 1], tab[j]);
  15. }
  16.  
  17. int main()
  18. {
  19. cout << "Podaj ilosc liczb chcesz wpisac" << endl << ">";
  20. cin >> ilosc;
  21. tab = new int[ilosc];
  22.  
  23. for (int i = 0; i < ilosc; i++)
  24. {
  25. cout << "Podaj " << i + 1 << " liczbe: ";
  26. cin >> tab[i];
  27. }
  28.  
  29. sortowanie_babelkowe(tab, ilosc);
  30. for (int i = 0; i<ilosc; i++)
  31. {
  32. cout << tab[i] << " ";
  33. }
  34. _getch();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment