Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int tab[10]={3,2,7,8,5,6,9,7,2,4};
- void echange (int i, int j){
- int tmp = tab [i];
- tab [i]=tab [j];
- tab [j]=tmp;
- }
- void fct (int gauche, int droit){
- int i, dernier;
- if(gauche>=droit)
- return;
- echange(gauche, (gauche+droit)/2);
- dernier=gauche;
- for(i=gauche+1;i<=droit;i++){//Here begins to order the vector
- if (tab[i]<tab[gauche])
- echange(++dernier,i);
- }
- echange (gauche,dernier);//In these lines I get confused.
- fct(gauche,dernier-1); //What do you intend to do here?
- fct(dernier+1,droit);
- }
- int main()
- {
- int i;
- fct(0,9);
- for(i=0;i<10;i++){
- printf("%d_",tab[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement