有参函数的调用

#include <iostream>
using namespace std;
int max(int x,int y,int z=0);

int main(){
    
    int a,b,c,m;

    
    cout<<"请你输入两个整型的数字:"<<endl;
    cin>>a>>b;
    m=max(a,b);
    cout<<"The max of a b and c is:"<<m<<endl;
    
    cout<<"请你输入三个整型的数字:"<<endl;
    cin>>a>>b>>c;
    m=max(a,b,c);
    cout<<"The max of a b and c is:"<<m<<endl;
    
    return 0;
}

int max(int x,int y,int z){
    if(z>x)
    x=z;
    if(y>x)
    x=y;
    return x;
}

posted @ 2017-11-09 21:47  羿龙  阅读(281)  评论(0编辑  收藏  举报