#include <iostream>
#include <string>
#define MAXSIZE 100
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
using namespace std;
#include "fact.h"
struct student{
int stuID;
float score;
};
struct SqListStu{
student *ElemStu;//数组首元素的地址
int length;
};
//顺序表的初始化
void InitSqList(SqListStu &SqLExp){
SqLExp.ElemStu=new student[MAXSIZE];
if (SqLExp.ElemStu == NULL){
exit(FALSE);//申请地址失败
}
cout << sizeof(SqLExp.ElemStu)<< endl;
SqLExp.length = 0;
}
int main() {
student stuz;
stuz.stuID = 0001;
stuz.score = 100;
SqListStu sqstuz;
InitSqList(sqstuz);
cout << sqstuz.length << endl;
return 0;
}
//顺序表的销毁
void DestroySqList(SqListStu &SqLExp){
// cout << "3" << SqLExp.ElemStu->stuID << "score" << SqLExp.ElemStu->score << endl;
if (SqLExp.ElemStu){
delete SqLExp.ElemStu;//释放存储空间
}
// cout << "3" << SqLExp.ElemStu->stuID << "score" << SqLExp.ElemStu->score << endl;
}
// 清空顺序表
void ClearList(SqList &SqLExp){
SqLExp.length = 0;
}
//顺序表的取值
int GetElem(SqListStu SqLExp, int i, student &e){
if (i<1 || i>SqLExp.length){
return -1;
}
else{
e = SqLExp.ElemStu[i-1];
// cout<< e << endl;
return 0;
}
}
//顺序表的插入
int InsertList(SqListStu &SqLExp, int i, student e){
if (i<1 || i>SqLExp.length || SqLExp.length==MAXSIZE){
return -1;
}
for (int j=SqLExp.length-1;j>=i-1;j--){
SqLExp.ElemStu[j+1]=SqLExp.ElemStu[j];
}
SqLExp.ElemStu[i-1] = e;
SqLExp.length++;
return 0;
}
//顺序表的删除
int DeleteList(SqListStu &SqLExp , int i ,student e){
if (i<1 || i>SqLExp.length){
return -1;
}
e = SqLExp.ElemStu[i-1];
for (int j=i;j<=SqLExp.length-1;j++){
SqLExp.ElemStu[j-1] = SqLExp.ElemStu[j];
}
SqLExp.length--;
return 0;
}