JiXieShi 2024-06-21 15:33:39 +08:00
parent cd1bb16183
commit ac9e8f43de
1 changed files with 23 additions and 0 deletions

View File

@ -118,4 +118,27 @@ void Test_Queue() {
// 打印出队的值
printf("Pop value from front: %d\n", *popVal1);
printf("Pop value from rear: %c\n", *popVal2);
float val3 = 10.5;
pushFirst(deque, &val3); // 将10.5插入队首
double val4 = 20.5;
pushLast(deque, &val4); // 将20.5插入队尾
float *popVal3 = (float *) popFirst(deque); // 从队首出队
double *popVal4 = (double *) popLast(deque); // 从队尾出队
printf("Pop value from front: %f\n", *popVal3);
printf("Pop value from rear: %lf\n", *popVal4);
int nums[] = {10, 20, 30, 40, 50};
// 测试入队操作
for (int i = 0; i < 5; i++) {
pushFirst(deque, &nums[i]); // 将数组元素插入队首
}
// 测试出队操作
int *popVal;
for (int i = 0; i < 5; i++) {
popVal = (int *) popFirst(deque); // 从队首出队
printf("Pop value from front: %d\n", *popVal);
}
delQueue_List(deque);
}