#include #include using namespace std;

struct Student{ char id[13]; char name[21]; int age; };

int main() { int n; cin >> n; Student stu[n]; for(int i = 0; i < n; i++){ cin >> stu[i].id >> stu[i].name >> stu[i].age; } int maxAge = stu[0].age; int maxIndex = 0; for(int i = 1; i < n; i++){ if(stu[i].age > maxAge){ maxAge = stu[i].age; maxIndex = i; } } cout << stu[maxIndex].id << ' ' << stu[maxIndex].name << endl; return 0; }

C++ 结构体实现学生信息管理:查找年龄最大学生

原文地址: http://www.cveoy.top/t/topic/ojH4 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录