50

P4414 [COCI2006-2007#2] ABC

lrqSB @ 2024-11-19 12:53:03


#include<bits/stdc++.h>
using namespace std;int f,b,c;char d[3];
int main(){

cin>>f>>b>>c>>d;

if(f>b){
    swap(f,b);

}if(f>c){
    swap(f,c);

}if(f>b){
    swap(f,b);

}

for(int i=0;i<=2;i++){
    if(d[i]=='A'){
        cout<<f;
    }if(d[i]=='B'){
            cout<<b;
        }if(d[i]=='C'){
                cout<<c;
            }
            cout<<" ";
}
    }

by xuxingcheng @ 2024-11-19 19:33:47

@lrqSB 代码:


#include<bits/stdc++.h>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int a1=min(min(a,b),c);
    int c1=max(max(a,b),c);
    int b1=(a+b+c)-(a1+c1);
    string d;
    cin>>d;
    for(int i=0;i<d.size();i++){
        if(d[i]=='A'){
            cout<<a1<<" ";
        }
        if(d[i]=='B'){
            cout<<b1<<" ";
        }
        if(d[i]=='C'){
            cout<<c1<<" ";
        }
    }
    return 0;
}

上一页 |