/**/ #include <cstdio> #include<string> #include <iostream> #include <vector> using namespace std; struct inf{ int y; int m; int d; string name; string sex; }; int main(){ string nm; string xb; int y,m,d; inf temp; vector<inf>my; while(1){ string index; cin>>index; if("add"==index){ cin>>temp.name>>temp.sex>>temp.y>>temp.m>>temp.d; my.push_back(temp); }else if(index=="name"){ string tempname; cin>>tempname; for(int i=0;i<my.size();i++){ if(my[i].name==tempname){ cout<<my[i].name<<" "<<my[i].sex<<" "<<my[i].y<<"-"<<my[i].m<<"-"<<my[i].d<<endl; } } }else if(index=="sex"){ string tempsex; cin>>tempsex; for(int i=0;i<my.size();i++){ if(my[i].sex==tempsex){ cout<<my[i].name <<" "<<my[i].sex <<" "<<my[i].y<<"-"<<my[i].m<<"-"<<my[i].d<<endl; } } }else{ break; } } } |
Double click to view unformatted code.