用结构体记录数据,结构体内部构造函数初始化,用map维护结构体,查找可以再用一个map记录学生社团下标,添加就直接加入,修改就找到下标改就行了,删除可使用map的erase,输出信息就用map迭代器循环遍历输出
#include <iostream>
#include <map>
#include <cstring>
using namespace std;
struct st{//结构体
int ID;
string name;
string start_time;
int person_num;
string college;
string leader;
string tel;
st(int a, string b, string c, int d, string e, string f, string tel){
this->ID = a;
this->name = b;
this->start_time = c;
this->person_num = d;
this->college = e;
this->leader = f;
this->tel = tel;
}
st(){}
};
map<string, st> mp;
map<string, st>::iterator it;
void init(){//初始化
mp.clear();
}
void Add(){//添加
st x;
cin >> x.ID >> x.name >> x.start_time >> x.person_num >> x.college >> x.leader >> x.tel;
if(mp.find(x.name) != mp.end()){
cout << "重复\n";;
return;
}
mp[x.name] = x;
}
void Modify(){//修改
string name;
cin >> name;
st x = mp[name];
//自行修改
}
void DELETE(string name){//删除
mp.erase(name);
}
st FIND(string name){//查找
return mp[name];
}
void Print(){
for(it=mp.begin();it!=mp.end();it++){
cout << it->second.ID << " " << it->second.name << endl;
}
}