Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sortowanie(int tab[10], int lewa, int prawa)
- {
- int a=lewa, b=prawa, pom, x=tab[(lewa+prawa)/2];
- do
- {
- while(tab[a]<x)
- a++;
- while(tab[b]>x)
- b--;
- if(a<=b)
- {
- pom=tab[a];
- tab[a]=tab[b];
- tab[b]=pom;
- a++;
- b--;
- }
- }while(a<=b);
- if(lewa<b)
- sortowanie(tab,lewa,b);
- else if(prawa>a)
- sortowanie(tab,a,prawa);
- else
- {
- for(int i=0; i<10; i++)
- {
- cout<<tab[i]<<" ";
- }
- }
- }
- int main()
- {
- int t[10]={21,18,76,43,98,17,32,12,50,66}, l, p;
- sortowanie(t,l,p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement