Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- #include<time.h>
- using namespace std;
- int n, v[100];
- int sort_me_please(int k)
- {
- for(int i=1;i<n-1;i=i+k)
- {
- int minim=v[i];
- int loc=i;
- for(int j=i+1;j<=n;j++)
- {
- if(v[j]<minim)
- {
- minim=v[j];
- loc=j;
- }
- }
- swap(v[i],v[loc]);
- }
- }
- int main()
- {
- srand(time(0));
- n=rand()%20;
- for(int i=1;i<=n;i++) v[i]=rand()%1000;
- cout<<endl<<" Job: ";
- for(int i=1;i<=n;i++) cout<<v[i]<<" ";
- int step=(int)n/3;
- while(step>=1)
- {
- sort_me_please(step);step--;
- }
- cout<<endl<<"Completed: ";
- for(int i=1;i<=n;i++) cout<<v[i]<<" ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement