|
|
|
@ -1,42 +1,53 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
//#include "LinearList/SeqList.c"
|
|
|
|
|
//#include "LinearList/LinkList.c"
|
|
|
|
|
//#include "Stack/SeqStack.c"
|
|
|
|
|
//#include "Stack/LinkStack.c"
|
|
|
|
|
//#include "Queue/SeqQueue.c"
|
|
|
|
|
#include "Queue/LinkQueue.c"
|
|
|
|
|
//#include "Queue/LinkQueue.c"
|
|
|
|
|
#include "Sort/InsertSort.c"
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
|
|
int arr[] = { 21, 3, 92, 6, 9};
|
|
|
|
|
|
|
|
|
|
int n = sizeof(arr) / sizeof(arr[0]);
|
|
|
|
|
printf("%d\n",n);
|
|
|
|
|
insertSort(arr,n);
|
|
|
|
|
for (int i = 1; i < n; i++) {
|
|
|
|
|
printf("%d ", arr[i]);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
// int a =20;
|
|
|
|
|
// int *p =&a;
|
|
|
|
|
// printf("%d--",*p);
|
|
|
|
|
|
|
|
|
|
LinkQueue queue; // 定义一个链队列
|
|
|
|
|
initQueue(&queue); // 初始化队列
|
|
|
|
|
|
|
|
|
|
// 入队操作,向队列中添加元素
|
|
|
|
|
enQueue(&queue, 1);
|
|
|
|
|
enQueue(&queue, 2);
|
|
|
|
|
enQueue(&queue, 3);
|
|
|
|
|
|
|
|
|
|
// 判断队列是否为空
|
|
|
|
|
if (queueEmpty(&queue)) {
|
|
|
|
|
printf("Queue is empty\n");
|
|
|
|
|
} else {
|
|
|
|
|
printf("Queue is not empty\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 出队操作,从队列中删除元素
|
|
|
|
|
int x = deQueue(&queue);
|
|
|
|
|
printf("Delete element: %d\n", x);
|
|
|
|
|
|
|
|
|
|
// 再次判断队列是否为空
|
|
|
|
|
if (queueEmpty(&queue)) {
|
|
|
|
|
printf("Queue is empty\n");
|
|
|
|
|
} else {
|
|
|
|
|
printf("Queue is not empty\n");
|
|
|
|
|
}
|
|
|
|
|
// LinkQueue queue; // 定义一个链队列
|
|
|
|
|
// initQueue(&queue); // 初始化队列
|
|
|
|
|
//
|
|
|
|
|
// // 入队操作,向队列中添加元素
|
|
|
|
|
// enQueue(&queue, 1);
|
|
|
|
|
// enQueue(&queue, 2);
|
|
|
|
|
// enQueue(&queue, 3);
|
|
|
|
|
//
|
|
|
|
|
// // 判断队列是否为空
|
|
|
|
|
// if (queueEmpty(&queue)) {
|
|
|
|
|
// printf("Queue is empty\n");
|
|
|
|
|
// } else {
|
|
|
|
|
// printf("Queue is not empty\n");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 出队操作,从队列中删除元素
|
|
|
|
|
// int x = deQueue(&queue);
|
|
|
|
|
// printf("Delete element: %d\n", x);
|
|
|
|
|
//
|
|
|
|
|
// // 再次判断队列是否为空
|
|
|
|
|
// if (queueEmpty(&queue)) {
|
|
|
|
|
// printf("Queue is empty\n");
|
|
|
|
|
// } else {
|
|
|
|
|
// printf("Queue is not empty\n");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//顺序队列
|
|
|
|
|
// SeqQueue seqQueue;
|
|
|
|
|