week 3 make main.c

This commit is contained in:
2021-03-16 08:34:33 +08:00
parent 7c8cf9a2ca
commit 124fd714d7
3 changed files with 28 additions and 26 deletions

27
week3/main.c Normal file
View File

@@ -0,0 +1,27 @@
#include <stdio.h>
#include "stack.h"
/* test function */
int main() {
Stack stack;
double val;
CreateStack(&stack, 5);
Push(&stack, 5.0);
Push(&stack, 6.5);
Push(&stack, -3.0);
Push(&stack, -8.0);
DisplayStack(&stack);
if (Top(&stack, &val)) {
printf("Top: %f\n", val);
}
Pop(&stack, &val);
if (Top(&stack, &val)) {
printf("Top: %f\n", val);
}
while(!IsEmpty(&stack)) {
Pop(&stack, &val);
}
DisplayStack(&stack);
DestroyStack(&stack);
return 0;
}