线性表 - linear list
#include<bits/stdc++.h>
using namespace std;
template <typename elemtype>;
const int maxlen = 10000005;
struct arraylist_{
elemtype array_[maxlen];
int len;
};
void cinlist_(arraylist_& L){
L.len = 0;
}
int length_(arraylist_& L){
return L.len;
}
void insert_(arraylist_& L, int i, int x){
if(L.len == maxlen){
cout << "overflow" << endl;
return;
}
if(i < 1 || i > (L.len+1)){
cout << "out of range" << endl;
return;
}
for(int j = L.len; j >= i; j--){
L.array_[j+1] = L.array_[j];
}
L.array_[i] = x;
L.len++;
}
void delete_(arraylist_& L, int i, elemtype& x, bool give_){
if(i < 1 || i > L.len){
cout << "out of range" << endl;
return;
}
if(give_){
x = L.array_[i];
}
for(int j = i+1; j <= L.len; j++){
L.array_[j-1] = L.array_[j];
}
L.len--;
}
void find_delete_(arraylist_& L, elemtype x){
int i = 1;
while(i <= L.len && x != L.array_[i]){
i++;
}
if(i > L.len){
cout << "not find" << endl;
return;
}
for(int j = i+1; j <= L.len; j++){
L.array_[j-1] = L.array_[j];
}
L.len--;
}
int main(){
//code
return 0;
}
栈 - stack
#include<bits/stdc++.h>
using namespace std;
template <typename elemtype>;
const int m0 = 10000005;
struct stack_{
elemtype vec_[m0];
int top;
};
int main(){
//code
return 0;
}