вносим коррективы типа
перед прототипами функций и их телами. Собсно, заменяем конкретный тип данных - например целочисленный int на шаблон
Далее я изменил код ф-ции main() для наглядности:
она последовательно обррабатывает массив типа Int,float and char.
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
template<class abstr>
void CHELN_sort(abstr a[],long N);
template<class abstr>
void input(abstr a[],long N);
template<class abstr>
void output(abstr a[],long N);
void main(){
long N;
cout<<"N?\n";
cin>>N;
cout<<"for int"<<endl;
int *xint=new int[N];
input(xint,N);
output(xint,N);
CHELN_sort(xint,N);
output(xint,N);
cout<<"Press any key\a";
cout<<endl;
delete xint;
float *xfloat=new float[N];
cout<<"for float"<<endl;
input(xfloat,N);
output(xfloat,N);
CHELN_sort(xfloat,N);
output(xfloat,N);
cout<<"Press any key\a";
cout<<endl;
delete xfloat;
char *xchar=new char[N];
cout<<"for char"<<endl;
input(xchar,N);
output(xchar,N);
CHELN_sort(xchar,N);
output(xchar,N);
cout<<"Press any key\a";
cout<<endl;
getch();
}
template<class abstr>
void CHELN_sort(abstr a[],long N){
cout<<"CHELN_sort RUN\n";
for(int j=0;j<N-1;j++){
if(a[j]>a[j+1]){
a[j]=a[j]+a[j+1];
a[j+1]=a[j]-a[j+1];
a[j]=a[j]-a[j+1];
for(int i=j;i>0;i--){
if(a[i]<a[i-1]){
a[i]=a[i]+a[i-1];
a[i-1]=a[i]-a[i-1];
a[i]=a[i]-a[i-1];
}
else break;
}
}
}
}
template<class abstr>
void input( abstr a[],long N){
cout<<"Select type:"<<endl;
cout<<"1) Random"<<endl;
cout<<"2) Manually"<<endl;
char p=getch();
if(p=='1'){
for(int i=0;i<N;i++)
a[i]=(rand()%255)*0.1;
}
else{
for(int i=0;i<N;i++){
cout<<"a["<<i<<"]=";
cin>>a[i];
}
}
}
template<class abstr>
void output(abstr a[],long N){
cout<<"output ===\n";
for(int i=0;i<N;i++)
cout<<"a["<<i<<"]="<<a[i]<<" ("<<float(a[i])<<")"<<endl;
}