week 3 header file comment
This commit is contained in:
@@ -1,23 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Author: Walter
|
||||||
|
* Student ID: 1930006025
|
||||||
|
* Week_3
|
||||||
|
* Stack
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/* struct for stack */
|
||||||
typedef struct Stack_str {
|
typedef struct Stack_str {
|
||||||
|
/* the size of stack */
|
||||||
int size;
|
int size;
|
||||||
|
/* top index, empty is -1 */
|
||||||
int top;
|
int top;
|
||||||
|
/* data */
|
||||||
double *data;
|
double *data;
|
||||||
} Stack;
|
} Stack;
|
||||||
|
|
||||||
|
/* create an stack with size */
|
||||||
bool CreateStack(Stack *stack, int size);
|
bool CreateStack(Stack *stack, int size);
|
||||||
|
|
||||||
|
/* check a stack whether it contains data */
|
||||||
bool IsEmpty(Stack *stack);
|
bool IsEmpty(Stack *stack);
|
||||||
|
|
||||||
|
/* check full of stack */
|
||||||
bool IsFull(Stack *stack);
|
bool IsFull(Stack *stack);
|
||||||
|
|
||||||
|
/* get the top value of a stack */
|
||||||
bool Top(Stack *stack, double *x);
|
bool Top(Stack *stack, double *x);
|
||||||
|
|
||||||
|
/* add a value to stack */
|
||||||
bool Push(Stack *stack, double x);
|
bool Push(Stack *stack, double x);
|
||||||
|
|
||||||
|
/* delete a value from stack */
|
||||||
bool Pop(Stack *stack, double *x);
|
bool Pop(Stack *stack, double *x);
|
||||||
|
|
||||||
|
/* print the stack */
|
||||||
void DisplayStack(Stack *stack);
|
void DisplayStack(Stack *stack);
|
||||||
|
|
||||||
|
/* delete a stack */
|
||||||
void DestroyStack(Stack *stack);
|
void DestroyStack(Stack *stack);
|
||||||
|
|||||||
Reference in New Issue
Block a user