90分求助

P4414 [COCI2006-2007#2] ABC

@[13097554300qq_com](/user/1260455) 顺着你的思路改了一下 ```cpp #include<bits/stdc++.h> using namespace std; int e[5]; char s, d, f; int main() { ios::sync_with_stdio(0); cin.tie(0); for (int i = 1; i <= 3; i++) cin >> e[i]; cin >> s >> d >> f; sort (e + 1, e + 1 + 3); int a = e[1], b = e[2], c = e[3]; if (s == 'A'){ cout << a << " "; if (d == 'B') cout << b << " " << c << endl; else cout << c << " " << b; exit (0); } if (s == 'B'){ cout << b << " "; if (d == 'A') cout << a << " " << c << endl; else cout << c << " " << a; exit (0); } if (s == 'C'){ cout << c << " "; if (d == 'A') cout << a << " " << b << endl; else cout << b << " " << a <<endl; } return 0; } ```
by Score_Elevate @ 2024-07-12 13:18:21


@[13097554300qq_com](/user/1260455) 重点改了这一段 ```cpp if (s == 'A'){//先判断首字母再对于下一位字母判断即可 cout << a << " "; if (d == 'B') cout << b << " " << c << endl;//如果第二位不是b则直接反过来输出即可 else cout << c << " " << b; exit (0);//提前结束程序节省一点时间 } if (s == 'B'){ cout << b << " "; if (d == 'A') cout << a << " " << c << endl; else cout << c << " " << a; exit (0); } if (s == 'C'){ cout << c << " "; if (d == 'A') cout << a << " " << b << endl; else cout << b << " " << a <<endl; } ```
by Score_Elevate @ 2024-07-12 13:20:19


@[13097554300qq_com](/user/1260455) 第四个判断少一个空格
by zxz114514 @ 2024-07-15 20:07:55


@[Score_Elevate](/user/797451) 入门题需要这么改吗?(无嘲讽意思)
by zxz114514 @ 2024-07-15 20:09:52


|