一,代码源程序
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct inte{
char ch[20]; //整形变量名,且变量名不能超过 20 个字符
int val; //整型变量值
};
typedef struct inte interge;
/////////////////////////////以下设计的是链栈//////////////////////////////////
struct snode{
int data;
struct snode *next;
};
typedef struct snode slist;
typedef slist *link;
link push(link stack,int value)
{
link newnode;
newnode=(link)malloc(sizeof(slist));
if(!newnode)
{
printf("Memory allocation failure!!!");
return NULL;
}
newnode->data=value;
newnode->next=stack;
stack=newnode;
return stack;
}
link pop(link stack,int &value)
{
link top;
if(stack!=NULL)
{
top=stack;
stack=stack;
value=top->data;
free(top);