70分求助,AC必关

P4414 [COCI2006-2007#2] ABC

YuYi_official @ 2024-10-13 11:48:12

我太菜了

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,sum=0;
    char ch;
    cin>>a>>b>>c;
    sum=a+b+c;
    a=min(min(a,b),c);
    c=max(max(a,b),c);
    b=sum-(a+c);
    for(int i=1;i<=3;i++){
        cin>>ch;
        if (ch=='A')cout<<a<<" ";
        if (ch=='B')cout<<b<<" ";
        if (ch=='C')cout<<c<<" ";
    }
    return 0;
}

by YuYi_official @ 2024-10-13 11:52:32

被我自己蠢哭,怎么能直接在原变量上修改呢

我是蠢蛋

加个x,y,z就行了

    cin>>x>>y>>z;
    sum=x+y+z;
    a=min(min(x,y),z);
    c=max(max(x,y),z);
    b=sum-(a+c);

艹,此帖不删我当一辈子黑历史


by blue_peace @ 2024-10-13 11:52:36

@YuYi_official

#include <algorithm>
#include <iostream>

using namespace std;

int a[3];

int main() {
    for (int i= 0; i < 3; i++)
        cin >> a[i];
    sort(a, a + 3);
    for (int i = 0; i < 3; i++) {
        char c;
        cin >> c;
        cout << a[c - 'A'] << ' ';
    }
    cout << '\n';
}

by 天使宝贝 @ 2024-10-13 11:53:36

emm,你变量a已经被替换了啊,所以就wa了


by blue_peace @ 2024-10-13 11:54:38

@YuYi_official

a=min(min(a,b),c);
c=max(max(a,b),c);
b=sum-(a+c);

这一段改一下

int x=a,y=b,z=c;
a=min(min(x,y),z);
c=max(max(x,y),z);
b=sum-a-c;

by blue_peace @ 2024-10-13 11:55:40

@YuYi_official 啊?你已经改了? 亏我打那么久


by YuYi_official @ 2024-10-13 11:58:08

@blue_peace 因为我很快(?)【doge】


by zhy_aua @ 2024-10-16 22:36:51

@YuYi_official 不是哥们,洛古有防作弊,直接抄题解会被封(好歹改个变量名)


|