Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int ilosc, *tab;
- void sortowanie_babelkowe(int tab[], int n)
- {
- for (int i = 0; i<n; i++)
- for (int j = 1; j<n - i; j++)
- if (tab[j - 1]>tab[j])
- swap(tab[j - 1], tab[j]);
- }
- int main()
- {
- cout << "Podaj ilosc liczb chcesz wpisac" << endl << ">";
- cin >> ilosc;
- tab = new int[ilosc];
- for (int i = 0; i < ilosc; i++)
- {
- cout << "Podaj " << i + 1 << " liczbe: ";
- cin >> tab[i];
- }
- sortowanie_babelkowe(tab, ilosc);
- for (int i = 0; i<ilosc; i++)
- {
- cout << tab[i] << " ";
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment