纯纯小白,想了半天写了半天,一看题解竟然这么简单........
查看原帖
纯纯小白,想了半天写了半天,一看题解竟然这么简单........
847204
newlifenny楼主2023/11/12 13:14
/*思路就是,数字顺序固定,都是A,B,C,剩下的就是匹配位置了,用string去找对应位置,最后输出(好麻烦)*/
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>//把我知道的头文件都写上了:)
using namespace std;
int main() 
{
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 3);
	string t;
	cin >> t;
	int npa = t.find_first_of("A");
	int npb = t.find_first_of("B");
	int npc = t.find_first_of("C");
	int r1,r2,r3;
	r1 = npa == 0 ? a[0] : npb == 0 ? a[1] : a[2];
	r2 = npa == 1 ? a[0] : npb == 1 ? a[1] : a[2];
	r3 = npa == 2 ? a[0] : npb == 2 ? a[1] : a[2];
	cout << r1 << " " << r2 << " " << r3;
	return 0;
}
2023/11/12 13:14
加载中...