View Code of Problem 95

#include <iostream>
#include <cstdio>
using namespace std;
struct Stu{
    string name,sex;
    int y,m,d;
}stu[999];
int main(){
    string a,p,q;
    int k=0;
    while(cin>>a){
        if(a=="quit")
            break;
        else if(a=="add"){
            cin>>stu[k].name>>stu[k].sex>>stu[k].y>>stu[k].m>>stu[k].d;
            k++;
        }
        else if(a=="name"){
            cin>>p;
            for(int i=0;i<k;i++){
                if(p==stu[i].name){
                    cout<<stu[i].name<<" "<<stu[i].sex<<" "<<stu[i].y<<"-"<<stu[i].m<<"-"<<stu[i].d<<endl;;
                }
            }
        }
        else if(a=="sex"){
            cin>>q;
            for(int i=0;i<k;i++){
                if(q==stu[i].sex){
                    cout<<stu[i].name<<" "<<stu[i].sex<<" "<<stu[i].y<<"-"<<stu[i].m<<"-"<<stu[i].d<<endl;;
                }
            }
        }

    }
    return 0;
}






























Double click to view unformatted code.


Back to problem 95