Here's a sample code..The rest is yours..
void swap(int items[], int i1, int i2)
(
int t = 0;
t=items[i1];
items[i1]=items[i2];
items[i2]=t;
)
int main()
{
int n=0,m=0;
const int s=4;
int num[s]={4,1,2,3};
int old[s]={4,1,2,3};
for(;n<s;n++)
std::cout<<num[n]<<std::endl;
for(n=s-1;n>0;n--)
for(m=0;m<n;m++)
if(num[m]>num[m+1])
swap(num,m,m+1);
std::cout<<std::endl;
for(n=0;n<s;n++)
std::cout<<num[n]<<std::endl;
//...A few aid
for x=0 to s-1
for y=0 to s-1
if num[x] = old[y] then
the old pos=y
return 0;
//done
}
Last edited by cikara21; Dec 2nd, 2008 at 3:24 pm. Reason: :)