萌新求帮助最后运行结果比正确的多了几个乱码

头文件
#pragma onceconst int maxsize = 100;template class seqlist {public:seqlist() { length = 0; }seqlist(ElemType a[], int n);~seqlist() {}ElemType getelem(int i);int len();int locate(ElemType x);bool listempty();void insert(int i, ElemType x);ElemType deletelist(int i);void displist();private:ElemType date[maxsize];int length;};
定义
#include"seqlist.h"#includeusing namespace std;template seqlist::seqlist(ElemType a[], int n)//建立顺序表{if (n > maxsize) throw"参数非法";for (int i = 0; i <= n; i++)date[i] = a[i];length = n;}template ElemType seqlist::getelem(int i)//按位查找{if (i<1 || i>maxsize) throw "参数错误";return date[i - 1];}templateint seqlist::locate(ElemType e)//按值查找{for (int i = 0; i < length; i++){if (e == date[i])return i + 1;}return 0;}template bool seqlist::listempty()//判定是否为空表{return length = 0;}template int seqlist::len() //求线性表的长度{return length;}template void seqlist::displist()//输出线性表{for (int i = 0; i < length; i++)cout << date[i] << " ";cout << endl;}template void seqlist::insert(int i, ElemType e)//插入数据元素{if (length == maxsize) throw "顺序表已满,上溢";if (i<1 || i>length + 1) throw "参数错误";for (int j = length - 1; j >= i - 1; j--){date[j + 1] = date[j];date[i - 1] = e;length++;}}template ElemType seqlist::deletelist(int i)//删除数据元素{if (i<1 || i>length)throw"参数错误";ElemType e=date[i - 1];for (int j = i; j < length; j++)date[j - 1] = date[j];length--;return e;}
主程序
#includeusing namespace std;#include "seqlist.cpp"int main(){int r[10] = { 4,2,6,8,12,10,14,16,19,18 };seqlistL(r, 10);cout << "执行插入操作前数据为:" << endl;L.displist();L.insert(6, 11);cout << "执行插入操作后数据为:" << endl;L.displist();cout << "值为16的元素位置为:" << endl;cout << L.locate(16) << endl;cout << "执行删除第7个元素操
作,删除前数据为:" << endl;L.displist();L.deletelist(7);cout << "删除后数据为:" << endl;L.displist();return 0;}

你这排版谁能看懂,插入代码

img