#include<bits/stdc++.h> using namespace std; typedef struct{ char name[20]; char sex[10]; int year; int month; int day; }people; int main(){ char s[10]; people p[100]; int i = 0; while(cin>>s){ if(strcmp(s,"add")==0){ cin>>p[i].name>>p[i].sex>>p[i].year>>p[i].month>>p[i].day; i++; }else if(strcmp(s,"name")==0){ char name[20]; cin>>name; for(int j=0;j<i;j++){ if(strcmp(p[j].name,name)==0){ cout<<p[j].name<<" "<<p[j].sex<<" "<<p[j].year<<"-"<<p[j].month<<"-"<<p[j].day<<endl; } } }else if(strcmp(s,"sex")==0){ char sex[10]; cin>>sex; for(int j=0;j<i;j++){ if(strcmp(p[j].sex,sex)==0){ cout<<p[j].name<<" "<<p[j].sex<<" "<<p[j].year<<"-"<<p[j].month<<"-"<<p[j].day<<endl; } } }else{ break; } } } |
Double click to view unformatted code.