30分求助!

B3720 [语言月赛202303] Out for Dinner B

xibaby @ 2023-11-19 18:37:27

#include<bits/stdc++.h>
using namespace std;
long long n; char a,b; int y=10;
int main(){
    scanf("%lld%c%c",&n,&a,&b);
    if(a>b) swap(a,b);
    if(a=='B')
      if(b=='C') y=6;
      else y=8;
    else if(b=='C') y=7;
    printf("%lld",n*y/10);
    return 0;
}

by _d_h_f @ 2023-11-19 19:13:25

判断语句就出问题了,输入方式也不对, a、b 不是这么输入的

#include<bits/stdc++.h>
using namespace std;
long long n; char a,b; 
char c[4];int y=10;
int main(){
    scanf("%lld%s",&n,c);
    a=c[0],b=c[1];
    if(a>b) swap(a,b);
    if(a=='A')
        if(b=='A')  
            y=10;
        else if(b=='B')
            y=8;
        else 
            y=7;
    else if(a=='B')
        if(b=='B')
            y=8;
        else
            y=6;
    else
        y=7;
    printf("%lld",n*y/10);
    return 0;
}

by xibaby @ 2023-11-25 15:42:09

@_d_h_f 非常感谢!


|