求助!

P4414 [COCI2006-2007#2] ABC

wanjiawei2302 @ 2024-08-21 11:02:02

#include<stdio.h>
int main()
{
    int arr[3], i, j, sw;
    char ch[4];
    for (i = 0; i < 3; i++)
    {
        scanf("%d ", &arr[i]);
    }
    gets(ch);
    for (i = 0; i < 3; i++)
    {
        for (j = i; j < 3; j++)
        {
            if (arr[i] > arr[j])
            {
                sw = arr[i];
                arr[i] = arr[j];
                arr[j] = sw;
            }
        }
    }
    for (i = 0; i < 3; i++)
    {
        if (ch[i] == 'A')
            printf("%d ", arr[0]);
        if (ch[i] == 'B')
            printf("%d ", arr[1]);
        if (ch[i] == 'C')
            printf("%d ", arr[2]);
    }
    return 0;
}

请大家帮忙看看为什么零分


by jihanyu123 @ 2024-08-30 14:02:04

因为你善

--------不怎么华丽的分割线---------

#include<bits/stdc++.h>
using namespace std;
int a[10];
string s;
int main(){
    for(int i=1;i<=3;i++){
        cin>>a[i];
    }
    cin>>s;
    sort(a+1,a+4);
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            cout<<a[1];
        }
        if(s[i]=='B'){
            cout<<a[2];
        }
        if(s[i]=='C'){
            cout<<a[3];
        }
        cout<<" ";
    }
    return 0;
}

|