This is the code:
Sort. H file:
#include
using namespace std;
# define M 5
The template & lt; The class T>//class template
The class Sort
{
Private:
T a, [M].
Public:
Void Input ();//input number M
Void the Print ();//output number M
Void the sort ();//bubble sort (since)
Void sort2 ();//bubble sort (from big to small)
};
Sort. CPP file:
# include "Sort. H"
The template & lt; The class T>//class template
Void Sort
{
int i;
Cout & lt; <"Please enter" & lt;
{
Cin & gt;> A, [I].
}
}
The template & lt; The class T>//class template
Void Sort
{
int i;
Cout & lt; <"Input data for:";
For (I=0; I & lt; M; I++)
{
Cout & lt; }
Cout & lt;
The template & lt; The class T>//class template
Void Sort
{
Int I, j, temp.
For (I=0; I & lt; M - 1; I++)
{
For (j=0; J & lt; 1 - I; M - J++)
{
If (a [j] & gt; A [m + 1])
{
Temp=a, [j].
A [j]=a, a + 1 bonus to [j].
A=\ [j + 1];
}
}
}
}
Main. CPP file
# include "Sort. H"
The template & lt; The class T>//class template
Int main ()
{
The Sort of s;
S.I nput ();//as object to input array values
Supachai panitchpakdi rint ();/new input/output array values
S.s ort ();//the new input value since the childhood are
Supachai panitchpakdi rint ();//the value of the output is sorted
system("pause");
return 0;
}
CodePudding user response:
Reference:# include & lt; Iostream>
using namespace std;
# define M 5
The template & lt; The class T>//class template
The class Sort
{
Private:
T a, [M].
Public:
Void Input ();//input number M
Void the Print ();//output number M
Void the sort ();//bubble sort (since)
Void sort2 ();//bubble sort (from big to small)
};
//Sort. CPP file:
//# include "Sort. H"
The template & lt; The class T>//class template
Void SortM: : Input ()//Input number
{
int i;
Cout & lt; <"Please enter" & lt;For (I=0; I & lt; M; I++)
{
Cin & gt;> A, [I].
}
}
The template & lt; The class T>//class template
Void Sort: : Print ()//output number M
{
int i;
Cout & lt; <"Input data for:";
For (I=0; I & lt; M; I++)
{
Cout & lt; }
Cout & lt;}
The template & lt; The class T>//class template
Void Sort: : sort ()//bubble sort (since)
{
Int I, j, temp.
For (I=0; I & lt; M - 1; I++)
{
For (j=0; J & lt; 1 - I; M - J++)
{
If (a [j] & gt; A [m + 1])
{
Temp=a, [j].
A [j]=a, a + 1 bonus to [j].
A=\ [j + 1];
}
}
}
}
//the main CPP file
//# include "Sort. H"
//the template & lt; The class T>//class template
Int main ()
{
Sorts;//Sort s;
S.I nput ();//as object to input array values
Supachai panitchpakdi rint ();/new input/output array values
S.s ort ();//the new input value since the childhood are
Supachai panitchpakdi rint ();//the value of the output is sorted
system("pause");
return 0;
}