-
Notifications
You must be signed in to change notification settings - Fork 5
/
SeqStackTest.c
36 lines (28 loc) · 927 Bytes
/
SeqStackTest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "SeqStack.c"
void dump(SeqStack *S) {
printf("[top: %d --", S->top);
for (int i = 0; i <= S->top; i++) {
printf("%c,", S->data[i]);
}
printf("]\n");
}
int main(void) {
SeqStack s, *S = &s;
InitStack(S);
dump(S);
Push(S, 'a');
Push(S, 'b');
printf("top: %c\n", GetTop(S)); // b
char ch = Pop(S);
printf("got: %c, top: %c\n", ch, GetTop(S)); // b, a
// ===============================================================
int match = Expr(); // 输入一些小括号, 如 ((())
printf("bracket match: %d\n", match); // 打印小括号个数是否匹配, 如 0 不匹配
char word[10];
gets(word);
int sym;
sym = symmetry(word); // 输入一串字符, 如 abcba
printf("%s is symmetry: %d\n", word, sym); // 打印是否是回文, 如 1 是
printf("10 based number 3553 is 8 based number:");
conversion(3553, 8); // 6741
}