求c++编程..........
1.阅读下列程序,写出程序的功能,然后使用模板函数改写该程序并上机验证。
#include<iostream.h>
void exchange(int &x,int &y,int &z)
{
int temp1=y,temp2=z;
y=x; z=temp1; x=temp2;
}
void exchange(float &x,float &y,float &z)
{
float temp1=y,temp2=z;
y=x; z=temp1; x=temp2;
}
void exchange(double &x,double &y,double &z)
{
double temp1=y,temp2=z;
y=x; z=temp1; x=temp2;
}
void main()
{
int i,j,k;
cout<<"i,j,k=";
cin>>i>>j>>k;
exchange(i,j,k);
cout<<i<<'\t'<<j<<'\t'<<k<<endl;
float a,b,c;
cout<<"a,b,c=";
cin>>a>>b>>c;
exchange(a,b,c);
cout<<a<<'\t'<<b<<'\t'<<c<<endl;
double u,v,w;
cout<<"u,v,w=";
cin>>u>>v>>w;
exchange(u,v,w);
cout<<u<<'\t'<<v<<'\t'<<w<<endl;
}