重载

Posted on 2017-12-18 15:56  dragonliu欧美  阅读(84)  评论(0编辑  收藏  举报
 1 #include<iostream>
 2 using namespace std;
 3 int m(int x,int y,int z);
 4 short m(short q,short w,short e);
 5 double m(double a,double s,double d);  
 6 int main(){
 7     int a,b,c,min;
 8     cin>>a>>b>>c;
 9     min=m(a,b,c);
10     cout<<"the min is "<<min<<endl;
11 
12     short ac,bc,cc,minc;
13     cin>>ac>>bc>>cc;
14     minc=m(ac,bc,cc);
15     cout<<"the min is "<<minc<<endl;
16     
17     double ad,bd,cd,mind;
18     cin>>ad>>bd>>cd;
19     mind=m(ad,bd,cd);
20     cout<<"the min is "<<mind<<endl;
21     return 0;
22 }
23 inline int m(int x,int y,int z){
24        if(z<x)
25        x=z;
26        if(y<x)
27        x=y;
28        return x;
29    }
30    inline short m(short x,short y,short z){
31        if(z<x)
32        x=z;
33        if(y<x)
34        x=y;
35        return x;
36    }
37    inline double m(double x,double y,double z){
38        if(z<x)
39        x=z;
40        if(y<x)
41        x=y;
42        return x;
43    }