/*
功能:寻找三个数中最大的那个
*/
#include <iostream>
using namespace std;
int main()
{
int a,b,c,max;
cout<<"请输入三个整形数"<<endl;
cin>>a>>b>>c;
max=a;
if(max<b)
{
max=b;
if(max<c)
{
max=c;
}
}
else if(max<c)
{
max=c;
}
cout<<max<<endl;
return 0;
}
<strong>首先是寻找三个数的最大数</strong>
<strong>习惯性的分类讨论</strong>
<strong>if(a<b)中嵌套if(b<c)</strong>
<strong>else if(a>b&&a<c)</strong>
<strong>但是这个方法并不好,因为难以推广的n个</strong>