Represent null with INT_MAX in C, C++.

This commit is contained in:
krahets
2023-04-18 14:31:23 +08:00
parent ed8fa6aea3
commit 6723cdbc7e
11 changed files with 35 additions and 26 deletions

View File

@@ -48,7 +48,7 @@ void push(arrayStack *s, int num) {
int peek(arrayStack *s) {
if (s->size == 0) {
printf("stack is empty.\n");
return NIL;
return INT_MAX;
}
return s->data[s->size - 1];
}
@@ -57,7 +57,7 @@ int peek(arrayStack *s) {
int pop(arrayStack *s) {
if (s->size == 0) {
printf("stack is empty.\n");
return NIL;
return INT_MAX;
}
int val = peek(s);
s->size--;