yeah, im kinda stuck again ;/ need to sort an array in increasing order, and this is what i got so far (functions to sort arrays):
this is what the professor gave us a while back in class, but when i call up the function, (ie. sort(w,n) ) it doesnt do anything, and returns the values in the same order i entered them ;/Code:void swap(int x, int y){ int t; t=x; x=y; y=t; } int mPos(int w[], int n){ int mp=0; for(int i=1;i<n;i++) if(w[i]>w[mp]) mp=i; return mp; } void sort(int w[],int n){ int mp; for(int i=n;i>1;i--){ mp=mPos(w,i); swap(w[mp],w[i-1]); }}
any help/suggestions?



LinkBack URL
About LinkBacks


