学生管理系统,开头就出现问题了
#include<iostream>#include<iomanip>
#include<string>
#include<stdlib.h>
#include<string.h>
#include<fstream>
using namespace std;
struct student
{
char name[10];
char sex[10];
int classnum;
double phonenum;
char address[20];
char profession[20];
int stunum;
int highmath;
int english;
int linegeneration;
int os;
int programmingdesigh;
int sum;
int ave;
int num;
};
void showprogram();
void Tmenu( struct student stu[]);
void Smenu(int num,struct student stu[]);
void addf(struct student stu[]);
void addg(struct student stu[]);
void showclass(struct student stu[]);
void showall(int i,struct student stu[]);
void showfundation(int i, struct student stu[]);
void changef(struct student stu[]);
void changeg(struct student stu[]);
void del(struct student stu[]);
void search(struct student stu[]);
static int n;//学生条数
struct student stu[15];
void main ()
{
system("color 0A");
int choice; int username[15]; int i = 0; char ch;
int select = username[0];
int num = 10 * username[9] + username[10];
int classnum = username[8];
cout << "1.登陆 2.注册\n" << "请输入操作代码:\n";
cin >> choice;
switch (choice)
{
case 1:system("cls");
cout << "请输入您的学号或工号:";
getchar();
while (getchar() != '\n')
{
cin>>username[i];
i++;
}
system("pause");
switch (select)
{
case 1:
if (n == 0){ cout << "查无此人,请先注册!\n"; return; }
else
system("cls"); Smenu(num, stu); break;
case 2:system("cls"); Tmenu(stu); break;
}
break;
case 2:
system("cls");
addf(stu);
break;
}
}
void Smenu(int num,student stu[])
{
cout << " -----------------------------学生信息显示系统------------------------------------------\n";
cout << " | 1.显示本人信息 2.显示全部学生基本信息 3.显示本班级学生信息 | ";
cout << " | 4.显示本班级课表 |\n";
cout << " | 0.退出系统 |\n";
cout << " ---------------------------------------------------------------------------------------\n";
cout << " 请输入操作代码\n";
int select=0;
switch (select){
case 1: showall(num,stu);
case 2:showfundation(num, stu);
case 3:showclass( stu);
case 4:showprogram();
case 0:exit(0);
}
}
void Tmenu(student stu[])
{
cout << " -----------------------------班级信息编辑系统-------------------------------------------------\n";
cout << " | 1.修改学生基本信息 2.删除指定学生信息 |\n";
cout << " | 3.录入学生科目成绩 4.修改学生科目信息 |\n";
cout << " | 5.修改课表 |\n";
cout << " 请输入操作代码\n";
int select=0;
switch (select){
case 1: changef(stu);
}
}
void showprogram()
{
char a[5];
cout << "┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┓\n";
cout << "┃ ┃ 周一 ┃ 周二 ┃ 周三 ┃ 周四 ┃ 周五 ┃\n";
for (int i = 1; i < 6; i++)
{
cout << "┣━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━┫\n";
cout << "┃ 第" << i << "节 ┃";
for (int j = 1; j < 6; j++)
{
cin >> a; cout << "━━━━━━╋";
}
cout << "┗━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━┛\n";
}
system("pause");
}
void showall(int i,struct student stu[])
{
if (n == 0)
{
cout << "请先录入学生信息!"; return;
}
int j = 0;
for (j = 0; j < n; j++)
showfundation(i,stu);
}
void showfundation(int i, struct student stu[])
{
cout << "姓名:" << stu[i].name << "\t";
cout << "性别:" << stu[i].sex << "\t";
cout << "班级:" << stu[i].classnum << "\t";
cout << "学号:" << stu[i].stunum << "\t";
cout << "专业:" << stu[i].profession << "\t";
cout << "手机:" << stu[i].phonenum << "\t";
cout << "家庭住址:" << stu[i].address << "\t";
}
void showclass(struct student stu[])
{
int classnum, i;
if (n == 0){
cout << "请先录入学生信息!";
}
else
cout << "请输入查看班级号\n";
cin >> classnum;
for (i = 0; i < n; i++)
{
if (classnum == stu[i].classnum)
cout << stu[i].name << "\n";
}
}
void addf(struct student stu[])
{
int i; char Name[10]; char YN;
cout << "**********学生注册***********\n";
do{
cout << "请输入:\n"<<"姓名:"; cin >> Name;
for (i = 0; i < n; i++)
{
if (strcmp(Name, stu[n].name) == 0)
{
cout << "该生已存在!\n";
return;
}
}
ofstream fin("d:\\file.txt");
cout << "性别:"; cin >> stu[n].sex;
cout << "学号:"; cin >> stu[n].stunum;
cout << "手机:"; cin >> stu[n].phonenum;
cout << "住址:"; cin >> stu[n].address;
n++;
cout << "还要添加么?填Y或者N:"; cin >> YN;
} while (YN == 'Y');
return;
}
void addg(struct student stu[])
{
int i, Num; char YN;
if (n == 0){
cout << "请先录入学生信息!";
return;
}
do {
cout << "请输入学号:"; cin >> Num; int j = 0;
for (i = 0; i < n; i++)
if (stu[i].stunum == Num)
{
cout << "请输入高数成绩:"; cin >> stu[i].highmath;
cout << "请输入英语成绩:"; cin >> stu[i].english;
cout << "请输入线性代数成绩:"; cin >> stu[i].linegeneration;
cout << "请输入操作系统成绩:"; cin >> stu[i].os;
cout << "请输入程序设计成绩:"; cin >> stu[i].programmingdesigh;
cout << "总分:" << (stu[i].highmath + stu[i].english + stu[i].linegeneration + stu[i].os + stu[i].programmingdesigh);
cout << "均分:" << (stu[i].highmath + stu[i].english + stu[i].linegeneration + stu[i].os + stu[i].programmingdesigh) / 5;
n++; j++;
cout << "是否继续添加?填Y或者N:"; cin >> YN;
}
if (j == 0)cout << "该生不存在!";
} while (YN == 'Y');
return;
}
void changef(struct student stu[])
{
int select;
if (n == 0){
cout << "请先录入学生信息!";
}
char Name[10]; char Sex[10]; int Classnum; int Stunum; double Phonenum; char Address[20]; char Profession[20]; int i;
cout << "请输入想要修改的学生学号:"; cin >> Stunum;
for (i = 0; i < n; i++)
if (stu[i].stunum == Stunum)
{
cout << "请输入要修改的项目序号: (1.姓名 2.性别 3.班级 4.学号 5.专业 6.手机 7.家庭住址)" << "\n"; cin >> select;
switch (select){
case 1:cout << "请输入新的姓名:"; cin >> Name; strcpy_s(stu[i].name , Name);
case 2:cout << "请输入新的性别:"; cin >> Sex;
case 3:cout << "请输入新的班级:"; cin >> Classnum; stu[i].classnum = Classnum;
case 4:cout << "请输入新的学号:"; cin >> Stunum; stu[i].stunum = Stunum;
case 5:cout << "请输入新的专业:"; cin >> Profession;
case 6:cout << "请输入新的手机号:"; cin >> Phonenum; stu[i].phonenum = Phonenum;
case 7:cout << "请输入新的家庭住址:"; cin >> Address;
}
}
}