mirror of
https://github.com/krahets/hello-algo.git
synced 2026-02-11 06:35:39 +08:00
Represent null with INT_MAX in C, C++.
This commit is contained in:
@@ -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--;
|
||||
|
||||
Reference in New Issue
Block a user