ABS + 分支语句
2023-09-15 17:35:26
发布于:上海
15阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int time1 = abs(a - c) + abs(a - 1);
int time2 = abs(b - c) + abs(b - 1) + abs(a - b);
if (time1 < time2) {
cout << "1" << endl;
} else if(time1 > time2) {
cout << "2" << endl;
} else {
cout << "3" << endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个