请问问题出在哪里呢运行不出来,望得到正确代码
-
- #include<iostream>
- #include<list>
- #include<windows.h>
- using namespace std;
- //定义结构体
- typedef struct
- {
- string name;
- int age;
- string sex;
- string id;
- string phone;
- }student;
- list<student> stulist;
- list<student>::iterator stu;
- int Select()
- {
- int select;
- cout << "\n输入选择:****************0.上一级****************1.继续****************"<<endl;
- cin>>select;
- return select;
- }
-
- //录入信息
- void inputStudent()
- {
- cout <<"\n姓名\t\t年龄\t\t性别\t\t学号\t\t电话"<<endl;
- Student data;
- cin >>data.name>>data.age>>data.sex>>data.id>>data.phone;
- stulist.push_back(data);
- int select = Select();
- loop1:
- if (select==0);
- else if (select==1)
- inputStudent();
- else{
- cout <<"错误请重新输入:";
- cin>>select;
- goto loop1;
- }
- return;
- }
- //浏览信息
- void printfStudent()
- {
- cout <<"\n姓名\t\t年龄\t\t性别\t\t学号\t\t电话"<<endl;
- for (stu = stulist.begin(); stu!=stulist.end(); stu++)
- cout<<(*stu).name<<"\t\t"<<(*stu).age<<"\t\t"<<(*stu).sex
- <<"\t\t"<<(*stu).id<<"\t"<<(*stu).phone
- <<endl;
- int select=Select();
- loop1:
- if (select==0);
- else if (select==1)
- printfStudent();
- else{
- cout <<"错误请重新输入:";
- cin>>select;
- goto loop1;
- }
- }
- //修改信息
- void changeStudent()
- {
- string str;
- bool f=true;
- cout<<"请输入需要修改信息的学生姓名:\n";
- cin>>str;
- for (stu = stulist.begin(); stu!=stulist.end(); stu++)
- if(str==(*stu).name)
- {
- cout<<"请输入需要修改后的学生信息:\n";
- cout <<"\n姓名\t\t年龄\t\t性别\t\t学号\t\t电话"<<endl;
- Student data;
- cin>>data.name>>data.age>>data.sex>>data.id>>data.phone;
- *stu=data;
- cout<<"已修改";
- f=!f;
-
- }
- if(f)
- cout <<"不存在该信息!"<<endl;
- int select =Select();
- loop1:
- if(select==0);
- else if (select==1)
- changeStudent();
- else
- {
- cout<<"发生错误,请重新输入:";
- cin>>select;
- goto loop1;
- }
- return;
- }
- //删除信息
- void delectStudent()
- {
- string str;
- bool f=true;
- cout<<"\n请输入需要删除信息的学生姓名:\n";
- cin>>str;
- for (stu = stulist.begin(); stu!=stulist.end(); stu++)
- if(str==(*stu).name)
- {
- stulist.erase(stu);
- cout<<"\n已删除";
- f=!f;
- break;
- }
-
- if(f)
- cout <<"\n不存在该信息!"<<endl;
- int select =Select();
- loop1:
- if(select==0);
- else if (select==1)
- deleteStudent();
- else
- {
- cout<<"选择错误,请重新输入:";
- cin>>select;
- goto loop1;
- }
- return;
- }
-
-
- //查找信息
- void searchStudent()
- {
- string str;
- bool f=true;
- cout<<"\n请输入需要查找信息的学生姓名:\n";
- cin>>str;
- for (stu = stulist.begin(); stu!=stulist.end(); stu++)
- if(str==(*stu).name)
- {
- cout <<"\n姓名\t\t年龄\t\t性别\t\t学号\t\t电话"<<endl;
- cout<<(*stu).name<<"\t\t"<<(*stu).age<<"\t\t"<<(*stu).sex
- <<"\t\t"<<(*stu).id<<"\t"<<(*stu).phone
- <<endl;
- f=!f;
- break;
- }
- if(f)
- cout <<"未查到该信息!"<<endl;
- int select =Select();
- loop1:
- if(select==0);
- else if (select==1)
- searchStudent();
- else
- {
- cout<<"选择错误,请重新输入:";
- cin>>select;
- goto loop1;
- }
- return;
- }
-
- //设计菜单页面
- void menu()
- {
- cout << "\n 学生信息管理系统\n\n"
- <<"*************************************************************************************\n\n"
- <<"\t\t\t\t0.退出系统\n\n"
- <<"\t\t\t\t1.录入信息\n\n"
- <<"\t\t\t\t2.浏览信息\n\n"
- <<"\t\t\t\t3.修改信息\n\n"
- <<"\t\t\t\t4.删除信息\n\n"
- <<"\t\t\t\t5.查找信息\n\n"
- <<"***************************************************************************************\n";
-
- }
-
- void keydown()
- {
- int choice{0};
- cin>>choice;
- switch (choice)
- {
- case 0:
- exit(0);
- break;
- case 1:
- system("cls");
- cout <<"\n****************************【录入信息】**********************************\n";
- inputStudent();
- break;
- case 2:
- system("cls");
- cout <<"\n****************************【浏览信息】**********************************\n";
- printfStudent();
- break;
- case 3:
- system("cls");
- cout <<"\n****************************【改变信息】**********************************\n";
- changeStudent();
- break;
- case 4:
- system("cls");
- cout <<"\n****************************【修改信息】**********************************\n";
- deleteStudent();
- break;
- case 5:
- system("cls");
- cout <<"\n****************************【查找信息】**********************************\n";
- searchStudent();
- break;
- default:
- cout<<"错误,请重新输入\n";
- system("pause");
- break;
-
- }
- }
-
- int main()
- {
- system("color F0");
- while (1)
- {
- system("cls");
- menu();
- keydown();
- }
- system("pause");
- return 0;
- }
-