Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int N = 5;
- void bubblesort(int* tablica)
- {
- for(int i = 0; i < N - 1; ++i)
- for(int j = 0; j < N - i - 1; ++j)
- if(tablica[j] > tablica[j + 1])
- swap(tablica[j], tablica[j + 1]);
- }
- void wypisz(int* tablica)
- {
- for(int i = 0; i < N; ++i)
- cout << tablica[i] << '\t';
- cout << endl;
- }
- int main()
- {
- int tablica[5] = {25, 17, 33, 10, 16};
- wypisz(tablica);
- bubblesort(tablica);
- wypisz(tablica);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment