我也是用的sort,为什么我会错?

P4414 [COCI2006-2007#2] ABC

@[wudengyuan](/user/1303889) code?
by Special_Tony @ 2024-03-13 21:17:22


@[Special_Tony](/user/743373) int a[4]; cin>>a[1]>>a[2]>>a[3]; sort(a+1,a+4); cout<<a[1]<<a[2]<<a[3];
by wumoumou_tyxx @ 2024-03-13 21:24:14


@[wudengyuan](/user/1303889) 你样例都没测?空格呢
by Special_Tony @ 2024-03-13 21:25:16


@[wudengyuan](/user/1303889) 另外你做法错的建议看题解
by Special_Tony @ 2024-03-13 21:26:30


@[Special_Tony](/user/743373) 谢~
by wumoumou_tyxx @ 2024-03-13 21:27:38


@[wudengyuan](/user/1303889) 你问题理解错了 首先,你少输入了三个字母A、B、与C。 其次,ABC分别代表最小,第二小,和最大。ABC的顺序是不一样的,所以用sort没用
by penguin_is_cool @ 2024-03-13 21:27:44


@[penguin_is_cool](/user/1065176) 好的,谢谢!
by wumoumou_tyxx @ 2024-03-13 21:28:29


@[wudengyuan](/user/1303889) code: ```cpp #include <iostream> #include <cmath> using namespace std; int main(){ int a,b,c,e,f; cin>>a>>b>>c; char A[3]; for (int i=0;i<3;i++){ cin>>A[i]; } for (int i=0;i<3;i++){ if (A[i]=='A')cout<<min(a,min(b,c))<<" "; else if (A[i]=='C')cout<<max(a,max(b,c))<<" "; else{ e=min(a,min(b,c)); f=max(a,max(b,c)); if (a!=f and a!=e)cout<<a<<" "; else if (b!=f and b!=e)cout<<b<<" "; else cout<<c<<" "; } } } ```
by penguin_is_cool @ 2024-03-13 21:28:35


6
by xiezi @ 2024-04-03 17:34:14


|