Operation result is wrong, should be 0123459876
Please reply to
CodePudding user response:
If I didn't look wrong, you are using VC6.0, give you a code for reference,
#include
#include
Typedef void * VoidPtr;
Typedef int * IntPtr;
/*
\ brief, ascending order
*/
Int asc (VoidPtr a, VoidPtr b)
{
Return * (IntPtr) - * (IntPtr) b;
}
/*
\ brief, descending order
*/
Int des (VoidPtr a, VoidPtr b)
{
The return - * * (IntPtr) b (IntPtr) a;
}
Int main (int arg c, char * argv [])
{
//assume array
Int arr []={5,6,0,1,2,3,8,9,4,7};
//for the array size
Int size=sizeof (arr)/sizeof (int);
//all ascending
Tree (arr, size, sizeof (int), asc);
//assume the location specified is 6
Int n=6;
//the specified location descending order
Tree & amp; Arr [6], size - n, sizeof (int), the des);
//print the results
For (size_t I=0; i{
Printf (" % d \ t ", arr [I]);
}
return 0;
}
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html