耗时0ms
2025-06-21 20:47:15
发布于:辽宁
5阅读
0回复
0点赞
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Alien {
string name;
int height, year;
};
int main() {
ios::sync_with_stdio(false); // 输入输出优化
cin.tie(NULL);
int n;
cin >> n;
vector<Alien> aliens(n); // 使用 vector 存储奥特曼信息
// 读取输入
for (int i = 0; i < n; ++i) {
cin >> aliens[i].name >> aliens[i].height >> aliens[i].year;
}
// 寻找最高奥特曼
int max_index = 0;
for (int i = 1; i < n; ++i) {
if (aliens[i].height > aliens[max_index].height || (aliens[i].height == aliens[max_index].height && aliens[i].year < aliens[max_index].year)) {
max_index = i;
}
}
// 输出结果
cout << aliens[max_index].name << " " << aliens[max_index].height << " " << aliens[max_index].year;
return 0;
}
这里空空如也
有帮助,赞一个