#include<bits/stdc++.h> using namespace std; struct student{ string name; string sex; int year; int month; int day; }; void add(student* a) { string n;string s;int y;int m;int d; cin>>n>>s>>y>>m>>d; a->name=n; a->sex=s; a->year=y; a->month=m; a->day=d; } void nam(student a[],string n,int j) { cin>>n; for(int i=0;i<j;++i) if(a[i].name==n) cout<<a[i].name<<" "<<a[i].sex<<" "<<a[i].year<<"-"<<a[i].month<<"-"<<a[i].day<<endl; } void sexual(student a[],string s,int j) { for(int i=0;i<j;++i) if(a[i].sex==s) cout<<a[i].name<<" "<<a[i].sex<<" "<<a[i].year<<"-"<<a[i].month<<"-"<<a[i].day<<endl } int main(void) { string op; student stu[30]; int i=0; while(cin>>op) { if(op=="quit") break; if(op=="add") {add(&stu[i]);++i;} if(op=="name") nam(stu,op,i); if(op=="sex") { cin>>op; sexual(stu,op,i); } } } /* Main.cc: In function 'void sexual(student*, std::__cxx11::string, int)': Main.cc:34:91: error: expected ';' before '}' token cout<<a[i].name<<" "<<a[i].sex<<" "<<a[i].year<<"-"<<a[i].month<<"-"<<a[i].day<<endl ^ ; } ~ */ |
Double click to view unformatted code.