1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include<iostream>
#include<string>
using namespace std;
template <typename T>
T getMax(T v1,T v2,T v3)
{
if(v1>v2 && v1>v3)
{
return v1;
}
else if(v2>v3)
{
return v2;
}
else
{
return v3;
}
}
int main()
{
int a,b,c;
float a1,b1,c1;
char a2,b2,c2;
string a3="Yi",b3="yile",c3="hello";
cout<<"Enter 3 value: \n";
cin>>a>>b>>c;
cout<<"Enter 3 floats:\n";
cin>>a1>>b1>>c1;
cout<<"Enter 3 chars:\n";
cin>>a2>>b2>>c2;
cout<<"Enter 3 strings:\n";
cout<<"The biggest value is: "<<getMax(a,b,c)<<endl;
cout<<"The biggest floats is: "<<getMax(a1,b1,c1)<<endl;
cout<<"The biggest chars is: "<<getMax(a2,b2,c2)<<endl;
sizeof a3;
sizeof b3;
sizeof c3;
cout<<"The biggest chars is: "<<getMax(a3,b3,c3)<<endl;
system("pause");
}
|