#include <iostream>
#include <vector>
#include <cstdlib> // For rand() and srand()
#include <ctime> // For time()
using namespace std;
int main() {
// 初始化随机数种子
srand(time(0));
// 定义一个包含52个学生名字的向量
vector<string> students;
students.push_back("张三");
students.push_back("李四");
students.push_back("王五");
students.push_back("赵六");
students.push_back("孙七");
students.push_back("周八");
students.push_back("吴九");
students.push_back("郑十");
students.push_back("刘十一");
students.push_back("陈十二");
students.push_back("杨十三");
students.push_back("黄十四");
students.push_back("高十五");
students.push_back("林十六");
students.push_back("何十七");
students.push_back("郭十八");
students.push_back("马十九");
students.push_back("罗二十");
students.push_back("梁二十一");
students.push_back("宋二十二");
students.push_back("谢二十三");
students.push_back("韩二十四");
students.push_back("唐二十五");
students.push_back("冯二十六");
students.push_back("于二十七");
students.push_back("董二十八");
students.push_back("萧二十九");
students.push_back("程三十");
students.push_back("曹三十一");
students.push_back("袁三十二");
students.push_back("邓三十三");
students.push_back("许三十四");
students.push_back("傅三十五");
students.push_back("沈三十六");
students.push_back("曾三十七");
students.push_back("彭三十八");
students.push_back("吕三十九");
students.push_back("苏四十");
students.push_back("卢四十一");
students.push_back("蒋四十二");
students.push_back("蔡四十三");
students.push_back("贾四十四");
students.push_back("丁四十五");
students.push_back("魏四十六");
students.push_back("薛四十七");
students.push_back("叶四十八");
students.push_back("阎四十九");
students.push_back("余五十");
students.push_back("潘五十一");
students.push_back("杜五十二");
// 已点名的学生向量
vector<string> called;
cout << "班级共有 " << students.size()+2 << " 名学生。\n";
while (!students.empty()) {
// 随机选择一名学生
int index = rand() % students.size();
string student = students[index];
// 将这名学生从待抽取列表中移除,并加入到已点名列表
students.erase(students.begin() + index);
called.push_back(student);
cout << "点名: " << student << endl;
// 打印已点名和未点名的学生列表
cout << "\n当前情况:" << endl;
cout << "已点名学生:";
for (vector<string>::iterator it = called.begin(); it != called.end(); ++it) {
cout << *it << " ";
}
cout << "\n未点名学生:";
for (vector<string>::iterator it = students.begin(); it != students.end(); ++it) {
cout << *it << " ";
}
cout << "\n\n";
// 暂停,等待用户按任意键继续
cout << "请按任意键继续点名...\n";
cin.get();
cin.ignore();
}
return 0;
}