求最大值

纵然是瞬间 提交于 2020-02-25 16:06:27

编写函数max(int a, int b, int c),求3个整数的最大值,并通过main函数进行调用。

#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(a,b,c);
    return 0;
}
int max(int a, int b, int c)
{
 int max=0;
 max=a;
 if(max<b)
 {
  max=b;
 }
 if(max<c)
 {
  max=c;
 }
 return max; 
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!