Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int n=30;
- int tab[n];
- for (int g=0;g<n;g++)
- {
- tab[g]=rand()%50;
- cout<<tab[g]<<" ";
- }
- cout<<endl<<endl;
- for(int i=0;i<n;i++)
- {
- for(int j=n-1;j>=0;j--) //użycie for(int j=0;j<=n-1;j++) powoduje, że pierwsze 13 wyrazów jest nieuporządkowane
- {
- if(tab[j]>tab[j+1])
- swap(tab[j],tab[j+1]);
- }
- cout<<tab[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment