#include <bits / STDC ++ H.> #include <math.h> #include < String > a using namespace std; // 5 Ge map variables to establish title, author, keyword, publisher and year of publication with id mapping respectively relationship Map < String , SET < int >> mpTitle, mpAuthor, mpKey, mpPub, mpYear; void Query (Map < String , SET < int >> & MP, String & STR) { IF (mp.find (STR) == mp.end ()) { the printf ( " Not Found \ n- " ); }else{ for(set<int>::iterator it = mp[str].begin();it != mp[str].end();++it){ printf("%d\n",*it); } } } int main(){ int n,m,id,type; string title,author,key,pub,year; scanf("%d",&n);//书的数目 for(int i =0;i<n;++i){ scanf("%d",&id); chargetchar = C (); // receiving id off wrap behind getline (CIN, title); // read the title of title mpTitle [title] .insert (id); getline (CIN, author); // read OF author mpAuthor [author] .insert (ID); the while (CIN >> Key) { mpKey [Key] .insert (ID); C = getchar (); IF (C == ' \ n- ' ) { BREAK ; } } getline (CIN, Pub); mpPub [Pub] .insert (ID); getline (CIN, year); mpYear [year] .insert (ID); } string temp; scanf("%d",&m); for(int i =0;i<m;++i){ scanf("%d:",&type); getline(cin,temp); cout<<type<<": "<<temp<<endl; if(type == 1){ query(mpTitle,temp); }else if(temp == 2){ query(mpAuthor,temp); }else if(temp == 3){ query(mpKey,temp); }else if(temp == 4){ query(mpPub,temp); }else{ query(mpYear,temp); } } system("pause"); return 0; }