Topic content:
Write a set of overloaded sorting functions that can order two integers, three integers, four integers, and integer arrays from large to small, with the function named sort, where the array sort should use the recursive method, and the print function to display the sorted array elements on one line.
The main functions are as follows:
int main ()
{
int a,b,c,d;
int data[100];
int k,n,i;
cin>>k;
Switch (k)
{
Case 1:
cin>>a>>b;
Sort (A, b);
cout<<a<< "" <<b<<endl;
Break
Case 2:
cin>>a>>b>>c;
Sort (a,b,c);
cout<<a<< "" <<b<< "" <<c<<endl;
Break
Case 3:
cin>>a>>b>>c>>d;
Sort (a,b,c,d);
cout<<a<< "<<b<<" "<<c<<" "<<d<<endl;
Break
Case 4:
cin>>n;
for (i=0;i<n;i++)
{
cin>>data[i];
}
Sort (data,n);
Print (data,n);
Break
}
return 0;
}
Input format:
Please analyze yourself according to the main program.
Output format:
Sorted data, one row, from large to small, with no spaces at the end.
Input Sample:
4
10
22 15 20 16 3 27 14 64 108 10
Sample output:
108 64 27 22 20 16 15 14 10 3
Please submit the complete program, including the given main ()
Sort function Overloading