样例没问题,但全WA 求C语言大佬

P4414 [COCI2006-2007#2] ABC

XLan_02 @ 2024-09-16 10:38:44


#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include<stdbool.h>
void max1(int *max,int *mid,int *min,int a,int b,int c){
    if(a>b){
        if(b>c){
            *min=c;
            *mid=b;
            *max=a;
        }else if(a<c){
            *min=b;
            *mid=a;
            *max=c;
        }else{
            *min=b;
            *mid=c;
            *max=a;
        }
    }else if(a>c){
        *max=b;
        *mid=a;
        *min=c;
    }else if(b>c){
        *max=b;
        *mid=c;
        *min=a;
    }else{
        *max=c;
        *mid=b;
        *min=a;
    }
}

int main() 
{   
    int a,b,c;
    int min,mid,max;
    int *p,*q,*u;
    p=&min;
    q=&mid;
    u=&max;
    char m[3];
    scanf("%d%d%d",&a,&b,&c);
    scanf("%s",&m);
    max1(u,q,p,a,b,c);
    int n[3];
    n[0]=min;
    n[1]=mid;
    n[2]=max;
    if(m[0]=='A'){
        if(m[1]=='B'){
            printf("%d %d %d",n[0],n[1],n[2]);
        }else{
            printf("%d %d %d",n[0],n[2],n[1]);
        }
    }else if(m[0]=='B'){
        if(m[1]=='A'){
            printf("%d %d %d",n[1],n[0],n[2]);
        }else{
            printf("%d %d %d",n[1],n[2],n[0]);
        }
    }else{
        if(m[1]=='A'){
            printf("%d %d %d",n[2],n[0],n[1]);
        }else{
            printf("%d %d %d",n[2],n[1],n[0]);
        }
    }
    return 0;

}

by __yun__ @ 2024-09-16 11:07:02

@XLan_02 变量名不能叫maxmin


by XLan_02 @ 2024-09-17 14:02:06

@yun 换成其他名字也不行啊


by 1357911BCC @ 2024-09-21 22:17:15

#include <bits/stdc++.h>
using namespace std;
int a[3];
string s;

int main() {
    cin >> a[0] >> a[1] >> a[2];
    cin >> s;
    sort(a, a + 3);
    for (int i = 0; i < s.length(); i++) {
        cout << a[s[i] - 'A'] << " ";
    }
    return 0;
}

你试试这个


|