#include <iostream> #include <stack> #include <string> using namespace std; class Man{ public: string name; string sex; int year; int month; int day; void print(){ cout<<name<<" "<<sex<<" "<<year<<"-"<<month<<"-"<<day<<endl; } }; int main() { string s; Man people[30]; int i=0; while(cin>>s){ if(s=="quit") break; if(s=="add"){ getchar(); string name,sex; int year,month,day; cin>>name>>sex>>year>>month>>day; people[i].name=name; people[i].sex=sex; people[i].year=year; people[i].month=month; people[i].day=day; i++; } if(s=="name"){ getchar(); string name; cin>>name; for(int j=0;j<=i;j++){ if(people[j].name==name){ people[j].print(); } } } if(s=="sex"){ getchar(); string sex; cin>>sex; for(int j=0;j<=i;j++){ if(people[j].sex==sex){ people[j].print(); } } } } } |
Double click to view unformatted code.