(一)新生基本信息统计软件
有新生来报到,要逐个录入其信息,如:学生姓名,性别,专业,出生日期,家庭地址,英语入学成绩。要求设计链表类来实现,并统计学生人数。文本界面为:
1. 新增学生信息
2. 删除学生信息
3. 导入学生信息(已经保存于的文件信息)
4. 学生信息搜索(按姓名)
5. 学生信息统计(按专业或性别或年龄---年龄要自动计算)
6. 按英语成绩排序
7. 学生信息保存
8. 退出
******请选择:1
————————————————————————————————————————————————
年龄的统计需要 提取系统当前日期
#include <time.h>
time_t tt = time(NULL); //这句返回的只是一个时间cuo
tm* t= localtime(&tt);
printf("%d-%02d-%02d %02d:%02d:%02d\n",
t->tm_year + 1900,
t->tm_mon + 1,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec);
#include <iostream>
#include <fstream>
#include <cstring>
#include <windows.h>
#include <time.h>
using namespace std;
class Student //学生信息类
{
public:
Student() //构造
{
id="/0";
name="/0";
sex="/0";
major="/0";
adress="/0";
score=0;
year=0;
month=0;
date=0;
}
~Student() //析构
{
}
void Creat_List(Student *head); //创建链表
bool Unique_List(Student *head,string id);//查重链表
void Print_List(Student *head); //输出链表
void Delete_List(Student *head); //删除链表节点(根据学号)
void Search_List(Student *head); //链表检索 (根据姓名)
void Find_List(Student *head); //链表查找 (根据学号)
void Statistics_List(Student *head); //链表统计 (专业或性别或年龄)
void Sort_List(Student *head); //链表排序 (英语成绩)
void Out_File(Student *head); //写入文件
void In_File(Student *head); //读取文件
void Menu_List(Student *head); //菜单
private: //成员信息
string id;
string name;
string sex;
string major;
string adress;
int score;
int year;
int month;
int date;
Student *next;
};
bool Student::Unique_List(Student *head,string id) //学号查重的实现
{
Student *p1=head;
while(p1->next!=NULL)
{
if(p1->id==id)
{
cout<<"请勿输入重复学号的学生!\n";
return true;
}
p1=p1->next;
}
return false;
}
void Student::Creat_List(Student *head) //创建链表的实现 (可重复添加到尾部)
{
Student *p1=head;
int num;
cout<<"请输入您要添加的学生数量: \n";
cin>>num;
if(p1->next==NULL)
{
for(