#include<iostream>
using namespace std;int main()
{
int max(int a,int b,int c=0);
int a,b,c;
cout<<"Please enter a b c:";
cin>>a>>b>>c;
cout<<"max(a,b,c)="<<max(a,b,c)<<endl;
cout<<"max(a,b)="<<max(a,b)<<endl;
return 0;
}
int max(int a,int b,int c)
{
if(b>a) a=b;
if(c>a) a=c;
return a;
}
本文展示了一个使用 C++ 编写的简单函数示例,该函数用于找出三个整数中的最大值。通过命令行输入三个整数,程序将分别输出这三个数中的最大值以及前两个数中的最大值。

被折叠的 条评论
为什么被折叠?



