用带默认参数的函数实现,为什么求三个正整数的最大值时得出的结果是一串不知名数字
//带默认参数的函数实现
#include<iostream>
using namespace std;
//声明函数
int max(int x,int y,int z);
void main()
{
int a=0,b=0,c=0;
int m=0;
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
//求两个的最大值
m=max(a,b,c);
cout<<"max="<<m<<endl<<endl;
//求三个的最大值
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
cout<<"c=";
cin>>c;
m=max(a,b,c);
cout<<"max="<<max<<endl;
}
//定义函数
int max(int x, int y, int z=0)
{
if(y>x)
{
x=y;
}
if(z>x)
{
x=z;
}
return x;
}