题解
2025-03-05 20:54:33
发布于:浙江
7阅读
0回复
0点赞
比大小,可以用if判断也可以用max解决
if判断的代码如下:
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
if(a > b){
if(a > c){
cout << a;
} else {
cout << c;
}
} else if(b > c){
if(b > a){
cout << b;
} else {
cout << a;
}
} else if(c > a){
if(c > b){
cout << c;
} else {
cout << b;
}
}
return 0;
}
max函数解决就简单了,代码如下:
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
cout << max(max(a,b),c);
return 0;
}
这里空空如也
有帮助,赞一个