# include <iostream>
using namespace std ;
enum Sex {Male ,Female};
struct Date
{ int year ;
int month;
};
struct Mat
{ int no ;
Date date;
Sex sex;
char name[20];
};
const int total=100;
int count =0;
void insert (Mat mat[], int t );
void find (Mat mat[], int t );
void chang (Mat mat[], int t );
void del (Mat mat[], int t );
int main ()
{
L: cout <<"***** please input your news******"<<endl;
cout<<"录入(I),查询(S),删除(D)"<<endl;
cout<<"your choose ."<<endl;
char choice ;
cin>>choice ;
Mat students[total];
if(choice =='I')
{
insert ( students , total);
chang (students,total);
// cout<<count<<endl;
goto L;
}
if(choice =='S')
{
find(students, total);
goto L;
}
if (choice=='E')
return 0;
return 0;
}
void insert ( Mat mat[] ,int t)
{
T: int g=count;
cout <<"input your news"<<endl;
cout<<"your numbers : "<<endl;
cin >>mat[g].no;
cout<<"your name:"<<endl;
cin>>mat[g].name;
cout<<"birth-date : "<<endl;
cin>>mat[g].date.year>>mat[g].date.month;
int f;
cout<<" sex(0 is Male ,1 is Female)"<<endl;
cin>>f ;
mat[g].sex=(Sex)f;
count++;
// cout<<count<<endl;
cout<<"continue or go back(C/E)"<<endl;
char choi;
cin >>choi;
if(choi=='C')
goto T;
if (choi =='E')
return;
}
void find (Mat mat[], int t )
{
W: cout<<"按学号查寻(A)/姓名(B)/退出(E)"<<endl;
cout <<"your choice"<<endl;
char cho;
cin>>cho;
if(cho=='E')
return;
if(cho=='A')
{
G: cout<<"输入你要查询人的学号"<<endl;
int no;
cin>>no;
for (int k=0;k<=count;k++)
{ if(mat[k].no==no)
{
cout<<"xuehao is :"<<mat[k].no<<endl;
cout<<"name is :"<<mat[k].name<<endl;
cout<<"birth-date is :"<<mat[k].date.year<<','<<
mat[k].date.month<<endl;
if (mat[k].sex==(Sex)0)
cout<<"sex is Male: "<<endl;
else
cout<<"sex is Female"<<endl;
cout<<"continue or go to the starting(C/E) "<<endl;
char choi_2;
cout <<"your choice"<<endl;
cin>>choi_2;
if(choi_2=='C')
goto G;
if(choi_2=='E')
goto W ;
}
}
if (k>count)
{ cout<<"your input is error."<<endl;
goto W;
}
}
if (cho=='B')
{
K: cout<<"input your name."<<endl;
char name[20];
cin>>name;
for (int c=0;c<=count;c++)
{ int w=c;
// cout<<mat[w].name<<endl;
// cout<<name<<endl;
// cout<<count<<endl;
if(mat[w].name==name)
{
cout<<"xuehao is :"<<mat[w].no<<endl;
cout<<"name is :"<<mat[w].name<<endl;
cout<<"birth-date is :"<<mat[w].date.year<<','<<
mat[w].date.month<<endl;
if (mat[w].sex==(Sex)0)
cout<<"sex is Male: "<<endl;
else
cout<<"sex is Female"<<endl;
cout<<"continue or go to the starting(C/E) "<<endl;
char choi_3;
cout <<"your choice"<<endl;
cin>>choi_3;
if(choi_3=='C')
goto K;
if(choi_3=='E')
goto W ;
}
}
// cout<<count<<endl<<c<<endl;
if (c>count)
{ cout<<"your input is error."<<endl;
goto W;
}
}
}
void chang (Mat mat[],int t)
{
int d=0;
Mat ne;
for(;d<=count;d++)
{
int j=d+1;
for(;j<=count;j++)
{
if(mat[d].no<mat[j].no);
{
mat[d]=mat[j];
ne=mat[d];
mat[j]=ne;
}
}
}
}
回复Comments
作者:
{commentrecontent}