cout << "请输入对应功能的号码:"; cin >> choice;//输入用户的选择 cout << "****************************" << endl; switch (choice) { case 1:{ cout << "候选人的信息为:" << endl; for (int i = 0; i < candidates.getSize(); i++) { Candidate& _c = static_cast<Candidate&>(candidates[i]); _c.print(); } cout << "************共有" << candidates.getSize() << "人************" << endl; this->menu(); break; } case 2:{ cout << "选民的信息为:" << endl; for (int i = 0; i < voters.getSize(); i++) { Voter& _v = static_cast<Voter&>(voters.NextElement()); _v.print(); } cout << "************共有" << voters.getSize() << "人************" <<endl; this->menu(); break; } case 3:{ srand((unsigned)time(NULL)); election(candidates, voters); this->menu(); break; } case 0:{ delete c1; c1 = nullptr; delete c2; c2 = nullptr; delete c3; c3 = nullptr; delete c4; c4 = nullptr; delete c5; c5 = nullptr; delete v1; v1 = nullptr; delete v2; v2 = nullptr; delete v3; v3 = nullptr; delete v4; v4 = nullptr; delete v5; v5 = nullptr; delete v6; v6 = nullptr; delete v7; v7 = nullptr; delete v8; v8 = nullptr; delete v9; v9 = nullptr; delete v10; v10 = nullptr; delete v11; v11 = nullptr; delete v12; v12 = nullptr; delete v13; v13 = nullptr; delete v14; v14 = nullptr; delete v15; v15 = nullptr; cout << "投票结束!!!" << endl; exit(0); break; } default:{ cout << "你输入的数字不正确!" << endl; this->run(); break; }这是部分代码,为什么当我从键盘输入的值是字母的时候,运行的不是 default , 而是 case 0 ;
添加回答
举报
0/150
提交
取消