View Code of Problem 95

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

struct Stu{
	string name;
	string gender;
	int yy,mm,dd;
}stu[31];

int main(void){
	string s;
	int i=0;
	while(cin>>s){
		if(s[0]=='a'){
			
			cin>>stu[i].name>>stu[i].gender>>stu[i].yy>>stu[i].mm>>stu[i].dd;
			i++;
		}else if(s[0]=='n'){
			string name;
			cin>>name;
			for(int j=0;j<i;j++){
				if(stu[j].name==name){
					cout<<stu[j].name<<" "<<stu[j].gender<<" "<<stu[j].yy<<"-"
					<<stu[j].mm<<"-"<<stu[j].dd<<endl;
				}
			}
		}else if(s[0]=='s'){
			string gender;
			cin>>gender;
			for(int j=0;j<i;j++){
				if(stu[j].gender==gender){
					cout<<stu[j].name<<" "<<stu[j].gender<<" "<<stu[j].yy<<"-"
					<<stu[j].mm<<"-"<<stu[j].dd<<endl;
				}
			}
		}else break;
	}
} 

Double click to view unformatted code.


Back to problem 95