链队列
#include<stdio.h>#include<stdlib.h>#define max 100typedef int ElemType; typedef struct QueueNode{ ElemType data; struct QueueNode *next;}QueueNode; typedef struct{ QueueNode* front; QueueNode* rear;}Queue; //初始化Queue* initQueueNode() { QueueNode* node = (QueueNode*)malloc(sizeof(QueueNode));//node是头结点 Queue* q = (Queue*)malloc(sizeof(Queue)); node->data = 0; node->next = NULL; q->front = node; q->rear = node; return...
队列
队列是先进先出,像排队一样 #include<stdio.h>#include<stdlib.h>#define max 100typedef int ElemType; typedef struct { ElemType* data; int front; int rear;}Queue; //初始化Queue* initQueue() { Queue* q = (Queue*)malloc(sizeof(Queue)); q->data = (ElemType*)malloc(sizeof(ElemType)); q->front = 0; q->rear = 0; return q;} //出队ElemType outQueue(Queue* q) { if (q->front == q->rear) { printf(“空的”); return 0; } ElemType e =...
栈
栈是后进先出,像弹夹一样 #include<stdio.h>#include<stdlib.h>#define max 100typedef int ElemType; typedef struct { ElemType data[max]; int top;}Stack; //初始化void initStack(Stack* s) { s->top = -1;} //压栈/进栈int push(Stack* s, ElemType e) { if (s->top >= max - 1) { printf(“满了\n”); return 0; } s->top++; s->data[s->top] = e; return 1;} //出栈int pop(Stack s, ElemType e){ if (s->top == -1) { printf(“空的”); return...
韩语基础篇
日常生活单词:
双向链表
#include<stdio.h>#include<stdlib.h>typedef int ElemType; typedef struct node{ ElemType data; struct node *prev, *next; }Node; //初始化双向链表Node* initNode() { Node* head = (Node*)malloc(sizeof(Node)); head->data = 0; head->prev = NULL; head->next = NULL; return head;} //头插法int insertHead(Node* L, ElemType e) { Node* p = (Node*)malloc(sizeof(Node)); p->data = e; p->prev = L; p->next = L->next; if...
链表
#include<stdio.h>#include<stdlib.h>typedef int ElemType;typedef struct node { ElemType data; struct node* next;}Node; Node* initList() { Node* head = (Node*)malloc(sizeof(Node)); head->data = 0; head->next = NULL; return head;} //头插法int insertHead(Node* L, ElemType e)//L为头结点{ Node* p = (Node*)malloc(sizeof(Node)); p->data = e; p->next = L->next; L->next = p; return 1;} //遍历int listNode(Node* L)...