教教我

P4414 [COCI2006-2007#2] ABC

M15388049303 @ 2024-07-12 14:16:00

#include<bits/stdc++.h>
using namespace std;
int a,b,c,maxn,mid,zuixiao=101;
char A,B,C;
int main(){
    cin>>a>>b>>c;
    if(maxn<a){
        maxn=a;
    }
    if(maxn<b){
        maxn=b;
    }
    if(maxn<c){
        maxn=c;
    }
    if(zuixiao>a){
        zuixiao=a;
    }
    if(zuixiao>b){
        zuixiao=b;
    }
    if(zuixiao>c){
        zuixiao=c;
    }
    if(maxn>a&&a>zuixiao){
        mid=a;
    }
    if(maxn>b&&b>zuixiao){
        mid=b;
    }
    if(maxn>b&&b>zuixiao){
        mid=b;
    }
    cin>>A>>B>>C;
    if(A=='A'&&B=='B'&&C=='C'){
        cout<<maxn<<" "<<mid<<" "<<zuixiao;
    }
    if(A=='A'&&B=='C'&&C=='B'){
        cout<<maxn<<" "<<zuixiao<<" "<<mid;
    }
    if(A=='B'&&B=='C'&&C=='A'){
        cout<<mid<<" "<<zuixiao<<" "<<maxn;
    }
    if(A=='B'&&B=='A'&&C=='C'){
        cout<<mid<<" "<<maxn<<" "<<zuixiao;
    }
    if(A=='C'&&B=='A'&&C=='B'){
        cout<<zuixiao<<" "<<maxn<<" "<<mid;
    }
    if(A=='C'&&B=='B'&&C=='A'){
        cout<<maxn<<" "<<mid<<" "<<zuixiao;
    }
}

by copper_ingot @ 2024-07-12 14:18:47

    if(maxn>a&&a>zuixiao){
        mid=a;
    }
    if(maxn>b&&b>zuixiao){
        mid=b;
    }
    if(maxn>b&&b>zuixiao){
        mid=b;
    }

by copper_ingot @ 2024-07-12 14:19:37

哥你写了两个 b


by M15388049303 @ 2024-07-12 16:26:57

@copper_ingot

#include<bits/stdc++.h>
using namespace std;
int a,b,c,maxn,mid,zuixiao=101;
char A,B,C;
int main(){
    cin>>a>>b>>c;
    if(maxn<a){
        maxn=a;
    }
    if(maxn<b){
        maxn=b;
    }
    if(maxn<c){
        maxn=c;
    }
    if(zuixiao>a){
        zuixiao=a;
    }
    if(zuixiao>b){
        zuixiao=b;
    }
    if(zuixiao>c){
        zuixiao=c;
    }
    if(maxn>a&&a>zuixiao){
        mid=a;
    }
    if(maxn>b&&b>zuixiao){
        mid=b;
    }
    if(maxn>c&&c>zuixiao){
        mid=c;
    }
    cin>>A>>B>>C;
    if(A=='A'&&B=='B'&&C=='C'){
        cout<<maxn<<" "<<mid<<" "<<zuixiao;
    }
    if(A=='A'&&B=='C'&&C=='B'){
        cout<<maxn<<" "<<zuixiao<<" "<<mid;
    }
    if(A=='B'&&B=='C'&&C=='A'){
        cout<<mid<<" "<<zuixiao<<" "<<maxn;
    }
    if(A=='B'&&B=='A'&&C=='C'){
        cout<<mid<<" "<<maxn<<" "<<zuixiao;
    }
    if(A=='C'&&B=='A'&&C=='B'){
        cout<<zuixiao<<" "<<maxn<<" "<<mid;
    }
    if(A=='C'&&B=='B'&&C=='A'){
        cout<<maxn<<" "<<mid<<" "<<zuixiao;
    }
}

改完后还是20


by copper_ingot @ 2024-07-12 16:49:11

A<B<C

by copper_ingot @ 2024-07-12 16:50:18

除了最后一个if 以外其他都错了


by M15388049303 @ 2024-07-13 08:14:12

@copper_ingot 该怎么办呢,蒟蒻不知道。


by copper_ingot @ 2024-07-13 08:16:52

    if(A=='C'&&B=='B'&&C=='A'){
        cout<<maxn<<" "<<mid<<" "<<zuixiao;
    }
    if(A=='C'&&B=='A'&&C=='B'){
        cout<<maxn<<" "<<zuixiao<<" "<<mid;
    }
    if(A=='B'&&B=='A'&&C=='C'){
        cout<<mid<<" "<<zuixiao<<" "<<maxn;
    }
    if(A=='B'&&B=='C'&&C=='A'){
        cout<<mid<<" "<<maxn<<" "<<zuixiao;
    }
    if(A=='A'&&B=='C'&&C=='B'){
        cout<<zuixiao<<" "<<maxn<<" "<<mid;
    }
    if(A=='A'&&B=='B'&&C=='C'){
        cout<<zuixiao<<" "<<mid<<" "<<maxn;
    }
}

|