解题思路:用max直接来找最大值
当然,你也可以用sort
注意事项:个人感觉没有
参考代码:
//第一种
#include<iostream>
#include<fstream>
#include<algorithm>//文件头
using namespace std;
long long a,b,c;//变量
int main(){
cin>>a>>b>>c;//输入
cout<<max(a,max(b,c));//直接来找最大值输出
return 0;
}
//第二种
#include<iostream>
#include<fstream>
#include<algorithm>//文件头
using namespace std;
long long a[99999];//变量
int main(){
for(int i=1;i<=3;i++)
cin>>a[i];//输入
sort(a+1,a+3+1);//排序
cout<<a[1];//因为排序是从大到小,所以输出第一个就可以了
return 0;
}
0.0分
8 人评分