📄 学生成绩统计管理系统.cpp
字号:
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
class List;
class Time
{
public:
int year,month,day;
};
class ListNode
{
public:
friend class List;
ListNode()
{ No=age=0;
strcpy(name,"无");
strcpy(sex,"无");
link=NULL;
}
private :
int No,age; //学号,年龄
Time birth;
char name[80],sex[10];//姓名,性别
char department[200];
char learn[20];
char educational[100];
char major[100];
char school[100];
char address[200];
char ID_card [20];
char phone[20];
char job[100];
char zhicheng[100];
Time start;
char English[20];
char shuxue[20];
char C[20];
double sum;
ListNode *link;
};
//////////////////
class List
{
public:
List()
{ first=new ListNode;
first->link=NULL;
Nodesum=0;
}
int Insert(ListNode*);//插入一个节点
int Remove();//按学号删除
void Show_List();//显示学生信息
void DisplayOneStu();//显示一个学生的信息
int Set_No(ListNode *p);//数据输入
ListNode* Find_Link(int);//按学号查找同学的前一个同学的指针
ListNode * Find_Name(char *a );//
void Modify();
private:
int Nodesum;
ListNode *first;//指向头结点
};
int List::Set_No(ListNode *p)//数据输入
{
cout<<"学号:";cin>>p->No;
cout<<"姓名:";cin>>p->name;
cout<<"性别:Male or Female?"; cin>>p->sex;
cout<<"年龄:"; cin>>p->age;
cout<<"出生年\月\日(以空格格开):"; cin>>p->birth.year>>p->birth.month>>p->birth.day;
// char st[10]; gets(st);
cout<<"学习状况:"; cin>>p->learn;
cout<<"详细地址: "; cin>>p->address; // printf("p->address=%s\n",p->address);
//
cout<<"身份证号码:"; cin>>p->ID_card; //printf("p-ID=%s\n",p->ID_card);
cout<<"电话号码:";cin>>p->phone;
cout<<"入学时间:"; cin>>p->start.year>>
p->start.month>>p->start.day;
cout<<"班级:"; cin>>p->department;
cout<<"文凭:"; cin>>p->educational;
cout<<"专业:"; cin>>p->major;
cout<<"所在院校:"; cin>>p->school;
cout<<"职务:"; cin>>p->job;
cout<<"职称:"; cin>>p->zhicheng;
cout<<"英语:"; cin>>p->English;
cout<<"数学:"; cin>>p->shuxue;
cout<<"C ++"; cin>>p->C;
return 1;
}
int List::Insert(ListNode* ln)//插入
{
Nodesum++;
ListNode *p=first,*q;
// Set_No(ListNode *ln);
if(p->link==NULL)
{
ln->link=NULL;
first->link=ln;
return 1;
}
while(p&&p->No<=ln->No) { q=p; p=p->link; }
if(q->No==ln->No) return 0;//不能有相同的学号
if(p==NULL)//当p达到末尾
{
ln->link=NULL;
q->link=ln;
}
else
{ ln->link=p;
q->link =ln;
}
return 1;
}
ListNode* List::Find_Link(int Dum)//按学号查询
{
ListNode* p=first,*q;
while(p&&p->No!=Dum) //Be Careful Here while(p->No!=Dum&&p) is wrong
{
q=p;
p=p->link;
}
if(p==NULL)//没找到
{
cout<<"Find failure! No this Number!"<<endl;
return q;
}
else return q;
}
ListNode *List::Find_Name(char *st)//按名字查询
{
ListNode* p=first,*q;
while(p&&strcmp(p->name,st)!=0)//不能写while(strcmp(p->name,st)!=0&&p)
{
q=p;
p=p->link;
}
if(p==NULL)
{
cout<<"Find failure! No this Name"<<endl;
return q;
}
else return q;
}
void List::Modify()//修改信息
{
int n;
ListNode *p= new ListNode;
cout<<"请输入要修改的学生的学号:";
cin>>n;
p=Find_Link(n)->link;
if(p==NULL)
{
cout<<"Find failure!"<<endl;
return ;
}
cout<<"该学生当前的信息为:"<<endl;
printf("\t * * * * * * * * * * * * * * * * * * * * * * * * * * * \n");
// printf("\t * * \n");
printf("\t * 学生基本资料修改 * \n");
// printf("\t * * \n");
printf("\t * * * * * * * * * * * * * * * * * * * * * * * * * * * \n");
printf(" |----------------------------------------------------------------------|\n");
printf(" |*****************************学生基本信息*****************************|\n");
//printf(" |----------------------------------------------------------------------|\n");
printf(" |----------------------------------------------------------------------|\n");
printf(" | 学生号 | 姓 名 | 性 别 | 年 龄 | 出生年/月/日 |\n");//
printf(" |----------------------------------------------------------------------|\n");
printf(" | %-10d| %-11s|",p->No,p->name);
if(p->sex[0]=='F'||p->sex[0]=='f') printf(" 男 |");
else if(p->sex[0]=='M'||p->sex[0]=='m') printf(" 女 |") ;
else printf(" 无 | ");
printf(" %-7d| %6d/%-2d/%-6d|\n",p->age,p->birth.year,p->birth.month,p->birth.day);
printf(" |----------------------------------------------------------------------|\n");
printf(" |学习状况| 地址 | 身份证 | 电话 |\n");
printf(" |----------------------------------------------------------------------|\n");
printf(" | %-7s|%-17s|%-22s|%-20s|\n",p->learn,p->address,p->ID_card,p->phone);
printf(" |----------------------------------------------------------------------|\n");
printf(" |****************************学生管理信息******************************|\n");
printf(" |----------------------------------------------------------------------|\n");
printf(" | 班级 | 文凭 | 职称 | 职务 |\n");//
printf(" |----------------------------------------------------------------------|\n");
printf(" | %-16s| %-17s| %-17s| %-13s|\n",p->department,p->educational,p->zhicheng,p->job);
printf(" |----------------------------------------------------------------------|\n");
printf(" | 所在院校 | 专 业 | 入学时间 |\n");
printf(" |----------------------------------------------------------------------|\n");
printf(" | %-28s| %-20s| /%-4d/%-2d/%-2d |\n",p->school,p->major,p->start.year,p->start.month,p->start.day);
printf(" |----------------------------------------------------------------------|\n");
printf(" |****************************学生成绩统计情况**************************|\n");
printf(" |----------------------------------------------------------------------|\n");
printf(" | 英语 | 数学 | C |\n");
printf(" |----------------------------------------------------------------------|\n");
printf(" | %-7s | %-7s | %-7s |\n",p->English,p->shuxue,p->C);
printf(" |----------------------------------------------------------------------|\n");
Set_No(p);
}
int List::Remove()//信息删除
{
Nodesum--;
int n; cout<<"请输入要删除的学号:";
cin>>n;
ListNode *p=Find_Link(n),*q;
if(p->link==NULL)
{
cout<<"Delete Failure!"<<endl;
return 0;
}
else
{ q=p->link;
p->link=p->link->link;
}
printf("操作成功\n");
delete q;
return 0;
}
void List::DisplayOneStu()//查询一个学生的基本信息
{
ListNode *p=new ListNode;
pp:; cout<<"请选择要查询的方式"<<endl;
cout<<"1:学号"<<endl;
cout<<"2:姓名"<<endl;
int n; scanf("%d",&n);
if(n==1)
{ printf("请输入要查询的学号:");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -