c++ 数据结构问题,求大神,在线等!!!!!!! 为什么跑不了着急啊
#include<iostream>usingnamespacestd;unionData{charpost[20];intgrade;}dataPost;enumSex...
#include<iostream>
using namespace std;
union Data{
char post[20];
int grade;
}dataPost;
enum Sex{man,women}sexd;
struct Person{
char name[20];
int num;
Data dataPost;
enum Sex sexd;
};
struct Person student[2];
int main()
{
for (int i=0;i<2;i++)
{cout<<"输入第"<<i<<"一个人姓名"<<endl;
cin>>student[i].name;
cout<<"输入第"<<i<<"个人编号"<<endl;
cin>>student[i].num;
cout<<"输入第"<<i<<"个人职业"<<endl;
cin>>student[i].dataPost.post;
cout<<"输入第"<<i<<"个人班级"<<endl;
cin>>student[i].dataPost.grade;
cout<<"输入第"<<i<<"个人性别,如果男孩输入M,女孩W"<<endl;
char s=getchar();
if(s=='w'||s=='W')student[i].sexd=women;
else if(s=='m'||s=='M')student[i].sexd=man;
else cout<<"ERROR!";
}
return 0;
} 展开
using namespace std;
union Data{
char post[20];
int grade;
}dataPost;
enum Sex{man,women}sexd;
struct Person{
char name[20];
int num;
Data dataPost;
enum Sex sexd;
};
struct Person student[2];
int main()
{
for (int i=0;i<2;i++)
{cout<<"输入第"<<i<<"一个人姓名"<<endl;
cin>>student[i].name;
cout<<"输入第"<<i<<"个人编号"<<endl;
cin>>student[i].num;
cout<<"输入第"<<i<<"个人职业"<<endl;
cin>>student[i].dataPost.post;
cout<<"输入第"<<i<<"个人班级"<<endl;
cin>>student[i].dataPost.grade;
cout<<"输入第"<<i<<"个人性别,如果男孩输入M,女孩W"<<endl;
char s=getchar();
if(s=='w'||s=='W')student[i].sexd=women;
else if(s=='m'||s=='M')student[i].sexd=man;
else cout<<"ERROR!";
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询