新人求助、、
#include<iostream> #define N 100
using namespace std;
class Student
{
public:
Student(int n,char* nam,char s);
void SetName(char* n)
{
strcpy(name,n);
}
int GetNo()
{
return no;
}
string GetName()
{
return name;
}
char GetSex()
{
return sex;
}
private:
int no;
char name[16];
char sex;
};
Student::Student(int n,char* nam,char s)
{
no=n;
strcpy(name,nam);
sex=s;
}
int main()
{
Student *stu[N];
int num=0;
int y,m,d,no;
char sex;
char name[16];
int i,choose,choose1=1;
cout<<"\n\t\t======================================="<<endl;
cout<<"\t\t1:录入 2:显示 3:修改 0:退出"<<endl;
cout<<"\n输入您要进行的操作:";
cin>>choose;
while(choose!=0)
{
switch(choose)
{
case 1:
cout<<"请按学号、姓名、性别顺序输入学生信息"<<endl;
cin>>no>>name>>sex;
cin>>y>>m>>d;
stu[num++] = new Student(no,name,sex);
break;
case 2:
cout<<"学号、姓名、性别"<<endl;
for(i=0;i<num;i++)
cout<<(*stu[i]).GetNo()<<" "<<(*stu[i]).GetName()<<" "<<(*stu[i]).GetSex()<<endl;
break;
case 3:
cout<<"输入学号:";
cin>>no;
for(i=0;i<num;i++)
{
if(no==(*stu[i]).GetNo())
{
cout<<"\n\n1:名字修改 "<<endl;
cout<<"选择您要进行的修改方式:"<<endl;
cin>>choose1;
switch(choose1)
{
case 1:
cout<<"输入姓名:";
cin>>name;
(*stu[i]).SetName(name);
break;
}
break;
}
}
break;
}
cout<<"\n\t\t======================================="<<endl;
cout<<"\t\t1:录入 2:显示 3:修改 0:退出"<<endl;
cout<<"\n输入您要进行的操作:";
cin>>choose;
}
return 0;
}
似乎录入后成了死循环,求大神解答