Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int main()
- {
- bool wypierdalam;
- int n;
- cout<<"Podaj liczbe elementow: ";
- cin>>n;
- int *tab = new int [n];
- srand(time(NULL));
- for(int i=0; i<n; i++)
- {
- tab[i] = rand()%100;
- cout<< tab[i] << " ";
- }
- cout << endl;
- for(int j=0; j<n; j++)
- {
- wypierdalam = true;
- for (int i=0; i<n; i++)
- {
- if(tab[i]>tab[i+1])
- {
- swap(tab[i],tab[i+1]);
- wypierdalam = false;
- }
- cout << setw(4) << tab[i];
- }
- cout << endl;
- if (wypierdalam == true) break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement