模拟题 直接代码吧 题面写的太清楚了
#include<bits/stdc++.h> #include<unordered_map> using namespace std; #define BCZ "error" struct vup_Broadcast_information { int years; int month; int day; int hours; int minutes; int The_live_time; bool operator<(const struct vup_Broadcast_information& q)const { if (q.years != years) { return years< q.years; } if (q.month != month) { return month < q.month; } if (q.day != day) { return day < q.day; } if (q.hours != hours) { return hours < q.hours; } if (q.minutes != minutes) { return minutes < q.minutes; } return false; } }; struct vup { string name; //VUP出道的名称 string live_broadcasting_platform; //直播平台 string url; //直播间连接 string note; //VUP介绍信息 string state; //状态代码分为三种:单推代码:DD 拉黑代码:Shielding_for 纪念馆代码:Memorialize set<vup_Broadcast_information>vbi; }; map<string, int>cdbm; string zl; map<string, struct vup>a; int VUP_add(); int VUP_alter(); int VUP_alter_name(string name, string xgsj); int VUP_delete(); int VUP_query(); int VUP_add_Live_plan(); int VUP(); int DD_list(); int Shielding_for_list(); int Memorialize_list(); int VUP_add() { struct vup vupdd; cin >> vupdd.name >> vupdd.live_broadcasting_platform >> vupdd.url >> vupdd.note >> vupdd.state; if (a.find(vupdd.name) == a.end()) { a[vupdd.name] = vupdd; cout << "VUP_addY"<<endl; } else { cout << "VUP_addN" << endl; } return 0; } int VUP_alter() { string name,alter_zl,xgsj; cin >> name>>alter_zl>>xgsj; if (a.find(name) != a.end()) { switch (cdbm[alter_zl]) { case 10:VUP_alter_name(name,xgsj);break; case 11:a[name].live_broadcasting_platform = xgsj; break; case 12:a[name].url = xgsj; break; case 13:a[name].note = xgsj; break; case 14:a[name].state = xgsj; break; default:cout << BCZ << endl; break; } cout << "VUP_alterY"<< endl; }else { cout << "VUP_alterN" << endl; } return 0; } int VUP_alter_name(string name, string xgsj) { struct vup z = a[name]; z.name = xgsj; a.erase(name); a[xgsj] = z; return 0; } int VUP_delete() { string name; cin >> name; if (a.find(name) != a.end()) { a.erase(name); cout << "VUP_deleteY" << endl; } else { cout << "VUP_deleteN" << endl; } return 0; } int VUP_query() { string name; cin >> name; if (a.find(name) != a.end()) { cout << "name:" << a[name].name << endl; cout << "live_broadcasting_platform:" << a[name].live_broadcasting_platform << endl; cout << "url:" << a[name].url << endl; cout << "note:" << a[name].note << endl; cout << "state:" << a[name].state << endl; } else { cout << "VUP_queryN" << endl; } return 0; } int VUP_add_Live_plan() { struct vup_Broadcast_information xinxi; string name; cin >> name; cin >> xinxi.years >> xinxi.month >> xinxi.day >> xinxi.hours >> xinxi.minutes >> xinxi.The_live_time; if(a.find(name)!=a.end()){ if(a[name].vbi.insert(xinxi).second){ cout << "VUP_add_Live_planY" << endl; } else { cout << "VUP_add_Live_planN" << endl; } } else { cout << "VUP_add_Live_planN" << endl; } return 0; } int VUP() { string vupzl; while (true) { cin >> vupzl; switch (cdbm[vupzl]) { case 5:VUP_add(); break; case 6:VUP_alter(); break; case 7:VUP_delete(); break; case 8:VUP_query(); break; case 9:return 0; break; case 15:VUP_add_Live_plan(); break; default:cout<<BCZ<<endl; break; } } return 0; } int DD_list() { int jl = 0; cout << "DD_list:" << endl; for (auto& it : a) { if (it.second.state != "DD")continue; cout << "name:" << it.second.name << endl; cout << "live_broadcasting_platform:" << it.second.live_broadcasting_platform << endl; cout << "url:" << it.second.url << endl; cout << "note:" << it.second.note << endl; cout << endl; jl++; } if (jl == 0) { cout << "DD_listN" << endl; } return 0; } int Shielding_for_list() { int jl = 0; cout << "Shielding_for_list:" << endl; for (auto& it : a) { if (it.second.state != "Shielding_for")continue; cout << "name:" << it.second.name << endl; cout << "live_broadcasting_platform:" << it.second.live_broadcasting_platform << endl; cout << "url:" << it.second.url << endl; cout << "note:" << it.second.note << endl; cout << endl; jl++; } if (jl == 0) { cout << "Shielding_for_listN" << endl; } return 0; } int Memorialize_list() { int jl = 0; cout << "Memorialize_list:" << endl; for (auto& it : a) { if (it.second.state != "Memorialize")continue; cout << "name:" << it.second.name << endl; cout << "live_broadcasting_platform:" << it.second.live_broadcasting_platform << endl; cout << "url:" << it.second.url << endl; cout << "note:" << it.second.note << endl; cout << endl; jl++; } if (jl == 0) { cout << "Memorialize_listN" << endl; } return 0; } int Query_Live_plan() { int jl = 0; cout << "Query_Live_plan:" << endl; for (auto& it : a) { if (it.second.state != "DD")continue; for (auto& qz : it.second.vbi) { cout << "name:" << it.second.name<< endl; cout << "live_broadcasting_platform:"<< it.second.live_broadcasting_platform << endl; cout << "url:"<< it.second.url << endl; cout << "years:"<< qz.years<< endl; cout << "month:"<< qz.month<< endl; cout << "day:"<< qz.day<< endl; cout << "hours:"<< qz.hours<< endl; cout << "minutes:"<< qz.minutes << endl; cout << "The_live_time:"<< qz.The_live_time << endl; cout << endl; jl++; } } if (jl == 0) { cout << "Query_Live_planN" << endl; } return 0; } int Specify_query_Live_plan() { string name; cin >> name; cout << "Specify_query_Live_plan:" << endl; if (a.find(name) != a.end()) { for (auto& qz : a[name].vbi) { cout << "name:" << a[name].name << endl; cout << "live_broadcasting_platform:" << a[name].live_broadcasting_platform << endl; cout << "url:" << a[name].url << endl; cout << "state:" << a[name].state << endl; cout << "years:" << qz.years << endl; cout << "month:" << qz.month << endl; cout << "day:" << qz.day << endl; cout << "hours:" << qz.hours << endl; cout << "minutes:" << qz.minutes << endl; cout << "The_live_time:" << qz.The_live_time << endl; cout << endl; } } else { cout << "Specify_query_Live_planN" << endl; } return 0; } int cs() { cdbm["VUP"] = 10; cdbm["DD_list"] = 1; cdbm["Shielding_for_list"] = 2; cdbm["Memorialize_list"] = 3; cdbm["The_next_time_a_certain"] = 4; cdbm["add"] = 5; cdbm["alter"] = 6; cdbm["delete"] = 7; cdbm["query"] = 8; cdbm["next"] = 9; cdbm["name"] = 10; cdbm["live_broadcasting_platform"] = 11; cdbm["url"] = 12; cdbm["note"] = 13; cdbm["state"] = 14; cdbm["add_Live_plan"] = 15; cdbm["Query_Live_plan"] = 16; cdbm["Specify_query_Live_plan"] = 17; return 0; } int main() { freopen("11.in", " r ", stdin); freopen("11.out", " w ", stdout); cs(); while (1) { cin >> zl; switch (cdbm[zl]) { case 10:VUP(); break; case 1:DD_list(); break; case 2:Shielding_for_list(); break; case 3:Memorialize_list(); break; case 16:Query_Live_plan(); break; case 17:Specify_query_Live_plan(); break; case 4:return 0; break; default: { cout << BCZ << endl; }break; } } return 0; }