# 資料結構
[toc]
## 陣列(Array)
* 在中國稱作"數組"。
### 靜態陣列(Static Array)
### 動態陣列(Dynamic Array)
## 堆疊(Stack)
* 在中國稱作"棧"。
```c
#include <stdio.h>
#include <stdlib.h>
#define BOOL unsigned char
#define TRUE 1
#define FALSE 0
typedef struct
{
int* data;
int size;
} Stack;
Stack* StackCreate()
{
Stack* s = malloc(sizeof(Stack));
s->data = NULL;
s->size = 0;
return s;
}
void StackPush(Stack* obj, int val)
{
// 擴大stack和最小值陣列的空間
obj->data = realloc(obj->data, sizeof(int)*(obj->size + 1));
// 更新stack的內容
obj->data[obj->size] = val;
// 更新size
obj->size++;
}
void StackPop(Stack* obj)
{
// 確認堆疊有內容
if(obj->size > 0)
{
obj->size--;
}
}
int StackTop(Stack* obj)
{
// 確認堆疊有內容
if(obj->size > 0)
{
return obj->data[obj->size - 1];
}
else
{
return 0;
}
}
int isStackEmpty(Stack* obj)
{
return (obj->size == 0);
}
void StackFree(Stack* obj)
{
free(obj->data);
free(obj);
}
int main()
{
Stack* obj = StackCreate();
StackPush(obj, 11);
printf("stack top = %d\n", StackTop(obj));
StackPush(obj, 22);
printf("stack top = %d\n", StackTop(obj));
StackPush(obj, 33);
printf("stack top = %d\n", StackTop(obj));
StackPush(obj, 44);
printf("stack top = %d\n", StackTop(obj));
StackPop(obj);
printf("stack top = %d\n", StackTop(obj));
StackPush(obj, 55);
printf("stack top = %d\n", StackTop(obj));
StackFree(obj);
return 0;
}
```
## 佇列(Queue)
* 在中國稱作"隊列"。
## 鏈接串列(Linked List)
* 又稱"連結串列",在中國稱作"鏈表"。
### 單向鏈接串列
### 雙向鏈接串列
### 循環鏈接串列
## 雜湊表(Hash Table)
## 樹
## 圖