#include
#include
#include
/*字符操作函数*/
#include
#include
#define BUFFSIZE 32
#define COL 128
#define ROW 64
/*定义栈1*/
typedef struct node
{
int data;
struct node *next;
}STACK1;
/*定义栈2*/
typedef struct node2
{
char data;
struct node2 *next;
}STACK2;
/*下面定义两个栈基本操作*/
/*入栈函数*/
STACK1 *PushStack(STACK1 *top,int x)
{
STACK1 *p;
p=(STACK1 *)malloc(sizeof(STACK1));
if(p==NULL)
{
printf("ERROR\n!");
exit(0);
}
p->data=x;
p->next=top;
top=p;
return top;
}
/*出栈函数*/
STACK1 *PopStack(STACK1 *top)
{
STACK1 *q;
q=top;
top=top->next;
free(q);
return top;
}
/*读栈顶元素*/
int GetTop(STACK1 *top)
{
if(top==NULL)
{
printf("Stack is null\n");
return 0;
}
/*返回栈顶元素*/
return top->data;
}
/*取栈顶元素,并删除栈顶元素*/
STACK1 *GetDelTop(STACK1 *top,int *x)
{
*x=GetTop(top);
top=PopStack(top);
return top;
}
int EmptyStack(STACK1 *top) /*判栈是否为空*/
{
if(top==NULL)
return 1;
return 0;
}
/*入栈函数*/
STACK2 *PushStack2(STACK2 *top,char x)
{
STACK2 *p;
p=(STACK2 *)malloc(sizeof(STACK2));
if(p==NULL)
{
printf("error\n!");
exit(0);
}
p->data=x;
p->next=top;
top=p;
return top;
}
STACK2 *PopStack2(STACK2 *top) /*出栈*/
{
STACK2 *q;
q=top;
top=top->next;
free(q);
return top;
}
/*读栈顶元素*/
char GetTop2(STACK2 *top)
{
if(top==NULL)
{
printf("Stack is null\n");
return 0;
}
return top->data;
}
/*取栈顶元素,并删除栈顶元素*/
STACK2 *GetDelTop2(STACK2 *top,char *x)
{
*x=GetTop2(top);
top=PopStack2(top);
return top;
}
/*判栈是否为空*/
int EmptyStack2(STACK2 *top)
{
if(top==NULL)
return 1;
else
return 0;
}
/*随机发牌函数*/
void GenCard()
{
int num,i;
srand((unsigned)time(NULL));
for(i=0;i<4;i++)
{
num=rand()%13; /*大小随机数*/
printf("%d ",num);
}
}
/*中缀字符串e转后缀字符串a函数*/
void ExpressTransform(char *expMidd