Skip to content

Latest commit

 

History

History

prob5

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

授業中練習問題5

ソースコード:source.c

提出

1)
(ア) Pop
(イ) -1
(ウ) 0

2)
(ア) s.ptr: 7, s.stk[4]: 83
(イ) 47
(ウ) 47

3)
typedef struct {
    int max;
    int ptr;
    PhysCheck stk[MAX];
} PhysCheckStack;

int Push(PhysCheckStack *s, PhysCheck x) {
    if (s->ptr >= s->max) return -1;
    s->stk[s->ptr] = x;
    s->ptr++;
    return 0;
}

int Pop(PhysCheckStack *s, PhysCheck *x) {
    if (s->ptr <= 0) return -1;
    s->ptr--;
    *x = s->stk[s->ptr];
    return 0;
}