Going back years in my memory:
Code:
int i, ii;
int iArray[5] = { 2, 4, 5, 1, 3};
for ( i = 0; i < 5; i++)
{
for (ii = i + 1; ii < 5; ii ++)
{
if ( iArray[i] < iArray[ii])
{
int swap = iArray[i];
iArray[i] = iArray[ii];
iArray[ii] = swap;
}
}
}
Untested, but if memory serves than it is correct.
However if you are using C++ than do something like this:
Code:
#include <algorithm>
vector<int> iVec;
int x;
while (cin, x)
iVec.push_back(x);
sort ( iVec.begin(), iVec.end() );
Something to this effect works well in C++, however MSVC++ 6 does not support the C++ STL and therefore you can't use this on that particular compiler.