int main() { /*kamus*/ char g; boolean yn; /*algoritma*/ yn = false; do { printf("apakah anda ingin mengambil giliran pertama ? (y/n) : "); scanf("%c",&g); if ((g == 'y') || (g == 'Y') || (g == 'n') || (g == 'N')) yn =true; else printf("masukan anda salah\n"); } while (!yn); makempty(); if ((g == 'y') || (g == 'Y')) usr1st(); else com1st(); return 0; }
/* 创建一个栈,需要输入最大值 */ Stack create_stack(int maxsize) { Stack S; if(maxsize < MinSize) { printf("Stack size is too small\n"); return NULL; } S = malloc(sizeof(struct StackRecord)); if(S == NULL) { printf("Out of space\n"); return NULL; } S->array = malloc(sizeof(ElementType) * maxsize); if(S->array == NULL) { printf("Out of space\n"); return NULL; } S->capacity = maxsize; makempty(S); return S; }