Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
顺序表的实现——动态分配
//g++ 7.4.0 // 顺序表 动态分配 // malloc()申请一整片连续的存储空间 #include<stdlib.h> typedef int ElemType; #define InitSize 10 typedef struct { ElemType *data; int MaxSize; int length; } SeqList; void InitList(SeqList &L) { L.data=(ElemType *)malloc(InitSize*sizeof(ElemType)); L.length=0; L.MaxSize=InitSize; } void IncreaseSize(SeqList &L, int len) { ElemType *p=L.data; L.data=(ElemType *)malloc((L.MaxSize+len)*sizeof(ElemType)); for(int i=0; i<L.length; i++) L.data[i]=p[i]; L.MaxSize+=len; free(p); } int main() { SeqList L; InitList(L); IncreaseSize(L, 5); return 0; }
run
|
edit
|
history
|
help
0
friend function
cppPyTeleAbs
HashTabFold
ADAKOHL - hpclearn
Test 1(2021)
Exempel 2
HI
RuntimeError
Peg Grammar AST Parser Computer Language Interpreter
ignat2