题目描述
利用默认参数的函数实现求2个或3个整数的最大值。
输入
输入3个int型整数。
输出
输出第1、2个整数及其最大值;
输出第1、2、3个整数及其最大值。
示例输入
88 66 99
示例输出
88 66 88
88 66 99 99
#include<iostream>
using namespace std;
int max(int x,int y,int z=-32767)
{
if(x<y)
x=y;
if(x<z)
x=z;
return x;
}
int main()
{
int a,b,c;
cin>>a>>b>>c;
int x,y;
x=max(a,b);
y=max(a,b,c);
cout<<a<<" "<<b<<" "<<x<<endl;
cout<<a<<" "<<b<<" "<<c<<" "<<y<<endl;
return 0;
}