/*
* @Author:
* @data: 2019-12-02 13:46:20
* @Last Modified by:
* @Last Modified time: 2019-12-03 20:18:30
*/
#include <iostream>
#include <cstdio>
using namespace std;
#define MAXSIZE 100
typedef int Status;
typedef int Elem;
typedef struct
{
/* data */
Elem *data; //这里其实是整了个数组
int len;
} SqList;//Sq 是 Squence的意思
//初始化
Status InitList(SqList &L)
{
L.data = new Elem[MAXSIZE]; //申请 内存
L.len = 0;
if (L.data)
return -1;
return 1;
}
//取值
Status GetList(SqList &L, int i, Elem &e)
{
if (i < 1 || i > L.len)
return -1;
e = L.data[i - 1];
return e;
}
//按值查找
Status Locatedata(SqList L, Elem e) //你可能要问了 为什么 这里没有&? 因为我查找不需要改它本身...
{
for (int i = 0; i < L.len; i++)
if (L.data[i] == e)
return i + 1;
return 1;
}
//插入
Status InsertList(SqList &L, int i, Elem e)
{
if (i < 1 || i > L.len + 1)
return -1;
if (L.len == MAXSIZE)
return -1;
for (int j = L.len; j >= i - 1; j--)
L.data[j + 1] = L.data[j]; //从后往前 覆盖
L.data[i - 1] = e; //猜猜为什么 是i-1? 因为 赋值那里 是从i=0开始的..
++L.len;
return 1;
}
//删除
Status DelList(SqList &L, int i)
{
if (i < 1 || i > L.len)
return -1;
for (int j = i; j < L.len - 1; j++)
L.data[j - 1] = L.data[j]; //依旧是覆盖 减总长
--L.len;
return 1;
}
//清空
Status DelAlList(SqList &L) //随便写的 应该成?...
{
L.data = NULL;
L.len = 0;
return 1;
}
int main()
{
SqList List;
//1
InitList(List);
int num;
cin >> num;
for (int i = 1; i <= num; i++)
{
Elem OBJ;
cin >> OBJ;
//1
InsertList(List, i, OBJ);
}
for (int i = 0; i < List.len; i++)
cout << List.data[i];
//1
DelAlList(List);
//Locatedata(List, 1);
///DelList(List, 1);
for (int i = 0; i < List.len; i++)
cout << List.data[i];
}