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 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <iostream>
#include <string>
using namespace std;
int min(int , int, int);
double min(double, double, double);
char min(char, char, char);
string min(string , string, string);
int main() {
int a(1), b(2), c(3);
double e=1.5, f=2.5, g=3.5;
char h='D', i='F', j='Z';
string k="firstname", l="surname", m="name";
cout<<"minimum of "<<a<<' '<<b<<' '<<c<<" is "<<min(a, b, c)<<endl;
cout<<"minimum of "<<e<<' '<<f<<' '<<g<<" is "<<min(e, f, g)<<endl;
cout<<"minimum of "<<h<<' '<<i<<' '<<j<<" is "<<min(h, i, j)<<endl;
cout<<"minimum of "<<k<<' '<<l<<' '<<m<<" is "<<min(k, l, m)<<endl;
system ("pause");
return 0;
}
int min(int x, int y, int z)
{
if(y<x && y<z)return y;
if (z<x && z<y) return z;
if( x<y && x<z ) return x;
}
double min(double x, double y, double z)
{
if(y<x && y<z)return y;
if (z<x && z<y) return z;
if( x<y && x<z ) return x;
}
char min(char x, char y, char z)
{
if(y<x && y<z)return y;
if (z<x && z<y) return z;
if( x<y && x<z ) return x;
}
string min(string x, string y, string z)
{
if(y<x && y<z)return y;
if (z<x && z<y) return z;
if( x<y && x<z ) return x;
}
|