#include #include #include using namespace std; class Students{ public: string student; string gender; int times; }; int main(){ map mapstudent; Students stu; cout << "请输入学生数量:"; cin >> stu.times; for(int i = 0; i < stu.times; ++i){ cout << "请输入学生姓名:"; cin >> stu.student; cout << "请输入学生性别:"; cin >> stu.gender; mapstudent[stu.gender] = stu.student; } for(auto it = mapstudent.begin(); it != mapstudent.end(); it++){ cout << "性别是:" << mapstudent.first() << "学生是:" << mapstudent.second() << endl; } }
使用了class map iostream string库,一大段代码。
上一篇 猜数字小游戏的实现
下一篇 第十一届蓝桥杯大赛第二场省赛试题C&C++ 大学B组真题 python实现
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号