题解 | #最大最小值#
最大最小值
https://ac.nowcoder.com/acm/contest/19304/M
#include<iostream> using namespace std; #include<algorithm> int main() { int a,b,c; cin>>a>>b>>c; if(a>b) { if(a>c) { cout<<"The maximum number is : "<<a<<endl; if(b>c)cout<<"The minimum number is : "<<c; else cout<<"The minimum number is : "<<b; } else if(c==b) { cout<<"The maximum number is : "<<b<<endl; cout<<"The minimum number is : "<<a; } else {cout<<"The maximum number is : "<<c<<endl; cout<<"The minimum number is : "<<b;} } else if(a<b) { if(c<b) { if(a>c) { cout<<"The maximum number is : "<<b<<endl; cout<<"The minimum number is : "<<c; } else if(a<c) { cout<<"The maximum number is : "<<b<<endl; cout<<"The minimum number is : "<<a; } else { cout<<"The maximum number is : "<<a<<endl; cout<<"The minimum number is : "<<b; } } else{ cout<<"The maximum number is : "<<c<<endl; cout<<"The minimum number is : "<<a; } } else { if(c>b) { cout<<"The maximum number is : "<<c<<endl; cout<<"The minimum number is : "<<a; } else if(c<b) { cout<<"The maximum number is : "<<b<<endl; cout<<"The minimum number is : "<<c; } else { cout<<"The maximum number is : "<<b<<endl; cout<<"The minimum number is : "<<c; } } }