AddrList.h
#include <iostream>
#include <iomanip>
#include <fstream>
#include <process.h>
#include <string.h>
using namespace std;
const int LIST_INIT_SIZE=10;
const int LISTINCREMENT=5;
//student,
typedef struct Contacts
{
char id[10]; //学号
char name[10]; //姓名
char sex[10]; //性别
char class_number[10]; //班级
char class_name[30]; //科目
char score[30]; //成绩
}Student;
//scorebook表
typedef struct scorebook
{
Student *elem;
int length;
int listsize;
int incrementsize;
}scorebook;
//错误运行
void ErrorMessage(char *s)
{
cout<<s<<endl;
exit(1); //非正常运行导致退出程序
}
//getchar()吸收换行来模拟暂停
void Pause()
{
cout<<endl<<"按任意键继续......";
getchar();getchar();
}
//初始化 length=0,获取 maxsize, incresize,new 长度为maxsize的student数组
void InitList_Sq(scorebook &L, int maxsize=LIST_INIT_SIZE, int incresize=LISTINCREMENT)
{
L.elem=new Student [maxsize];
L.length=0;
L.listsize=maxsize;
L.incrementsize=incresize;
}
//查找元素(按id学号查询)
int LocateElem_Sq(scorebook &L, Student e)
{
for(int i=0;i<L.length;i++)
if(strcmp(L.elem[i].id,e.id)==0) return i+1;
return 0;
}
//获取元素
void GetElem_Sq(scorebook &L, int i, Student &e)
{
e=L.elem[i-1];
}
//增加存储空间和长度
void increment(scorebook &L)
{
Student *p=new Student[L.listsize+L.incrementsize];
for(int i=0;i<L.length;i++)
p[i]=L.elem[i];
delete [] L.elem;
L.elem=p;
L.listsize=L.listsize+L.incrementsize;
}
//增加元素
void ListInsert_Sq(scorebook &L, Student e)
{
if(L.length>=L.listsize)
increment(L);
if(L.length ==0)
{
L.elem[0]=e;
L.length++;
}
else

本文介绍了如何使用顺序表或单链表实现一个学生成绩管理系统。系统基于一个包含学生编号、姓名、性别及各科成绩的结构体设计,实现了成绩录入、查询、删除、修改、输出、保存、排序和统计等功能。提供了头文件StuList.h和程序文件StuList.cpp,以菜单形式进行系统控制。源代码、实验报告和作业要求可在提供的链接中获取。
最低0.47元/天 解锁文章
2291

被折叠的 条评论
为什么被折叠?



