Solution for 10 to be sorted numbers:
#include
using namespace std;
void descend (float,float,float,float,float,float,float,float,float,float);
float max (float,float,float,float,float,float,float,float,float,float);
int main ()
{
float f1=1,f2=1,f3=1,f4=1,f5=1,f6=1,f7=1,f8=1,f9=1,f10=1;
cout << "Please enter 10 floating-point numbers\n";
cin>>f1;
cin>>f2;
cin>>f3;
cin>>f4;
cin>>f5;
cin>>f6;
cin>>f7;
cin>>f8;
cin>>f9;
cin>>f10;// Get the numbers
descend (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10);
return 0;
}
void descend (float d1,float d2,float d3,float d4,float d5,float d6,float d7,float d8,float d9,float d10)
{
int i;
float F = 1.0;
float small = 3.4e-38;
cout << "\n\nNumbers in descending order\n";
for (i=0;i<10;i++)
{
F = max (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10);
if (d1 == F)
d1 = small;
else if (d2 == F)
d2 = small;
else if (d3 == F)
d3 = small;
else if (d4 == F)
d4 = small;
else if (d5 == F)
d5 = small;
else if (d6 == F)
d6 = small;
else if (d7 == F)
d7 = small;
else if (d8 == F)
d8 = small;
else if (d9 == F)
d9 = small;
else if (d10 == F)
d10 = small;
}
}
float max (float d1,float d2,float d3,float d4,float d5,float d6,float d7,float d8,float d9,float d10)
{
float max;
max = d1;
if (max < d2)
max = d2;
if (max < d3)
max = d3;
if (max < d4)
max = d4;
if (max < d5)
max = d5;
if (max < d6)
max = d6;
if (max < d7)
max = d7;
if (max < d8)
max = d8;
if (max < d9)
max = d9;
if (max < d10)
max = d10;
cout << max << endl;
return max;
}
It's actually a little confusing in the hints that F is initiallized a very large number while it's just all right as long as it's initialized.
Thanks, everybody, especially lerner, he got the idea.