void LineEdit()
{
	SqStack s;
	char ch;

	InitStack(s);
	printf("请输入一个文本文件,^Z结束输入:\n");
	ch = getchar();
	while (ch != EOF) {
		while (ch != EOF && ch != '\n') {
			switch (ch) {
			case '#': if (!StackEmpty(s))
					Pop(s, ch);
				break;
			case '@': ClearStack(s);
				break;
			default: Push(s, ch);
			}
			ch = getchar();
		}
		StackTraverse(s, copy);
		fputc('\n', fp);
		ClearStack(s);
		if (ch != EOF)
			ch = getchar();
	}
	DestroyStack(s);
}
Exemple #2
0
void main()
{
	ElemType e;
	LiStack *s;
	printf("栈s的基本运算如下:\n");
	printf("  (1)初始化栈s\n");
	InitStack(s);
	printf("  (2)栈为%s\n",(StackEmpty(s)?"空":"非空"));
	printf("  (3)依次进栈元素a,b,c,d,e\n");
	Push(s,'a');
	Push(s,'b');
	Push(s,'c');
	Push(s,'d');
	Push(s,'e');
	printf("  (4)栈为%s\n",(StackEmpty(s)?"空":"非空"));
	printf("  (5)出栈序列:");
	while (!StackEmpty(s))
	{
		Pop(s,e);
		printf("%c ",e);
	}
	printf("\n");
	printf("  (6)栈为%s\n",(StackEmpty(s)?"空":"非空"));
	printf("  (7)释放栈\n");
	DestroyStack(s);
}
Exemple #3
0
int main()
{
    SqStack S;
    printf("(1)��ʼ��ջ��\n");
    InitStack (S);
    printf("(2)�ж�ջs�Ƿ�ǿգ�");
    if(StackEmpty(S))
        printf("�ǿ�\n");
    else printf("��\n");
    printf("(3)���ν�ջԪ��a,b,c,d,e:\n");
    push(S,'a');
    push(S,'b');
    push(S,'c');
    push(S,'d');
    push(S,'e');
    printf("(4)�ж�ջs�Ƿ�ǿգ�");
    if(StackEmpty(S))
        printf("�ǿ�\n");
    else printf("��\n");

    printf("(5)ջ�ij����ǣ�%d\n",StackLength(S));
    printf("(6)�����ջ����ջ��Ԫ��:");
    StackTraverse(S);
    printf("\n(7)�����ջ����:");
    StackGet(S);

    printf("\n(8)�ж�ջs�Ƿ�ǿգ�");
    if(StackEmpty(S))
        printf("�ǿ�\n");
    else printf("��\n");

    printf("(9)�ͷ�ջ");
    DestroyStack(S);

}
 static void LineEdit()
 { // 利用字符栈s,从终端接收一行并送至调用过程的数据区。算法3.2
   SqStack s;
   char ch,c;
   InitStack(s);
   printf("请输入一个文本文件,^Z结束输入:\n");
   ch=getchar();
   while(ch!=EOF)
   { // EOF为^Z键,全文结束符
     while(ch!=EOF&&ch!='\n')
     {
       switch(ch)
       {
         case '#':Pop(s,c);
                  break; // 仅当栈非空时退栈
         case '@':ClearStack(s);
                  break; // 重置s为空栈
         default :Push(s,ch); // 有效字符进栈
       }
       ch=getchar(); // 从终端接收下一个字符
     }
     StackTraverse(s,copy); // 将从栈底到栈顶的栈内字符传送至文件
     ClearStack(s); // 重置s为空栈
     fputc('\n',fp);
     if(ch!=EOF)
       ch=getchar();
   }
   DestroyStack(s);
 }
void lineEdit() {
	SqStack S;
	InitStack(S);
	char ch;
	ch = getchar();
	ElemType e;
	while (ch != EOF) {
		while (ch != EOF && ch != '\n') {
			switch (ch) {
			case '#': 
				Pop(S, e);
				break;
			case '@':
				ClearStack(S);
				break;
			default:
				e.key = ch;
				Push(S, e);
				break;
			}
			ch = getchar();
		}

		PrintStack(S);
		ClearStack(S);
		if (ch != EOF) ch = getchar();
	}
	DestroyStack(S);
}
 void LineEdit()
 { /* 利用字符栈s,从终端接收一行并送至调用过程的数据区。算法3.2 */
   SqStack s;
   char ch,c;
   InitStack(&s);
   printf("请输入一个文本文件,^Z结束输入:\n");
   ch=getchar();
   while(ch!=EOF)
   { /* EOF为^Z键,全文结束符 */
     while(ch!=EOF&&ch!='\n')
     {
       switch(ch)
       {
         case '#':Pop(&s,&c);
                  break; /* 仅当栈非空时退栈 */
         case '@':ClearStack(&s);
                  break; /* 重置s为空栈 */
         default :Push(&s,ch); /* 有效字符进栈 */
       }
       ch=getchar(); /* 从终端接收下一个字符 */
     }
     StackTraverse(s,copy); /* 将从栈底到栈顶的栈内字符传送至文件 */
     ClearStack(&s); /* 重置s为空栈 */
     fputc('\n',fp);
     if(ch!=EOF)
       ch=getchar();
   }
   DestroyStack(&s);
 }
 void LineEdit()
 { // 利用字符栈s,从终端接收一行并送至调用过程的数据区。算法3.2
   SqStack s;
   char ch,c;
   int n,i;
   InitStack(s);
   scanf("%d",&n);  //多case
   ch=getchar();
   for(i=1;i<=n;i++)
   { ch=getchar();
     while(ch!='\n')
    {
       switch(ch)
       {
         case '#':Pop(s,c);
                  break; // 仅当栈非空时退栈
         case '@':ClearStack(s);
                  break; // 重置s为空栈
         default :Push(s,ch); // 有效字符进栈
       }
       ch=getchar(); // 从终端接收下一个字符
     }
     StackTraverse(s,visit); // 将从栈底到栈顶的栈内字符输出
    ClearStack(s); // 重置s为空栈
    }
   DestroyStack(s);
 }
void conversion() {
	SqStack S;
	InitStack(S);
	int N;
	printf("input the decimal number:\n");
	scanf_s("%d", &N);
	printf("input the the number system after conversion:\n");
	int d;
	scanf_s("%d", &d);
	while (N) {
		ElemType e;
		e.key = N % d;
		Push(S, e);
		N = N / d;
	}
	PrintStack(S);
	printf("the conversion result is:\n");
	while (!StackEmpty(S)) {
		ElemType e;
		Pop(S, e);
		printf("%d", e.key);
	}
	printf("\n");
	PrintStack(S);
	DestroyStack(S);
}
void main()
{
	ElemType e;
	SqStack *s;
	printf("Õ»sµÄ»ù±¾ÔËËãÈçÏÂ:\n");
	printf("  (1)³õʼ»¯Õ»s\n");
	InitStack(s);
	printf("  (2)ջΪ%s\n",(StackEmpty(s)?"¿Õ":"·Ç¿Õ"));
	printf("  (3)ÒÀ´Î½øÕ»ÔªËØa,b,c,d,e\n");
	Push(s,'a');
	Push(s,'b');
	Push(s,'c');
	Push(s,'d');
	Push(s,'e');
	printf("  (4)ջΪ%s\n",(StackEmpty(s)?"¿Õ":"·Ç¿Õ"));
	printf("  (5)Õ»µÄ³¤¶È=%d\n",StackLength(s));  
	printf("  (6)Êä³ö´ÓÕ»¶¥µ½Õ»µ×ÔªËØ:");
	DispStack(s);  
	printf("  (7)³öÕ»ÐòÁУº");
	while (!StackEmpty(s))
	{
		Pop(s,e);
		printf("%c",e);
	}
	printf("\n");
	printf("  (8)ջΪ%s\n",(StackEmpty(s)?"¿Õ":"·Ç¿Õ"));
	printf("  (9)ÊÍ·ÅÕ»\n");
	DestroyStack(s);
}
void parenthesisMatch() {
	char s[100];
	printf("please input the string which consists of paretheses:\n");
	scanf("%s", s);
	SqStack S;
	InitStack(S);
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == '[' || s[i] == '{' || s[i] == '(') {
			ElemType e;
			e.key = s[i];
			Push(S, e);
		}
		else if (s[i] == ']' || s[i] == '}' || s[i] == ')') {
			ElemType e;
			Pop(S, e);
			if (e.key != s[i] - 1 && e.key != s[i] - 2) {
				printf("the parentheses are not matching.\n");
				return;
			}
		}
	}
	if (StackEmpty(S)) {
		printf("the parentheses are matching.\n");
	}
	DestroyStack(S);
}
Exemple #11
0
void LineEdit() {  // 算法3.2
  //利用字符栈S,从终端接收一行并传送至调用过程的数据区。
  char ch,*temp;
  SqStack S;
  InitStack(S);       //构造空栈S
  printf("请输入一行(#:退格;@:清行):\n");
  ch = getchar();     //从终端接收第一个字符
  while (ch != EOF) { //EOF为全文结束符
    while (ch != EOF && ch != '\n') {
      switch (ch) {
        case '#': Pop(S, ch);    break;  // 仅当栈非空时退栈
        case '@': ClearStack(S); break;  // 重置S为空栈
        default : Push(S, ch);   break;  // 有效字符进栈,未考虑栈满情形
      }
      ch = getchar();  // 从终端接收下一个字符
    }	
    temp=S.base;
    while(temp!=S.top) {
      printf("%c",*temp);	      	
      ++temp;
    }		
    // 将从栈底到栈顶的栈内字符传送至调用过程的数据区;
    ClearStack(S);      // 重置S为空栈
    printf("\n");
    if (ch != EOF) {
      printf("请输入一行(#:退格;@:清行):\n");
      ch = getchar();
    }
  }
  DestroyStack(S);
}
Exemple #12
0
int main()
{
	int j;
	SqStack s;
	SElemType e;

	if( InitStack(&s) == OK )
		for(j = 1; j <= 9; j++)
			Push(&s, j);

	printf("The items in the stack is: \n");
	StackTraverse(s, visit);

	Pop(&s, &e);
	printf("The item popped is: %d\n", e);
	printf("\n");

	printf("The stack is empty now? empty:1, not empty:0\t%d\n", StackEmpty(s));
	printf("\n");

	GetTop(s, &e);
	printf("The item at the top of the stack is: %d, the length of the stack is: %d\n",e, StackLength(s));
	printf("\n");

	ClearStack(&s);
	printf("The stack cleared, is the stack empty? empty:1, not empty:0, %d\n", StackEmpty(s));
	printf("\n");

	DestroyStack(&s);
	
	return 0;
}
Exemple #13
0
void LineEdit(){
	// P50 算法3.2 行编辑程序
	// #:退格 @:退行
	// 利用字符栈S,从终端接收一行并传送至调用过程的数据区
	SqStack S;
	InitStack(S);
	SElemType e;
	char ch = getchar();
	while (ch != EOF){
		while (ch != EOF && ch != '\n'){
			switch (ch){
				case'#': 
					Pop(S, e);
					break;
				case'@':
					ClearStack(S);
					break;
				default:
					Push(S, ch);
					break;
			}
			ch = getchar();	//从终端接收下一个字符
		}
		StackTraverse(S, Visit_Display_Char);
		ClearStack(S);
		if (ch != EOF) ch = getchar();
	}
	DestroyStack(S);
}// LineEdit
Exemple #14
0
void Queen(int * board, int n)
{
	Stack * StateStack;
	if ( CreateStack(&StateStack, sizeof(State), n * n) == false )
	{
		printf("Loi: Khong du bo nho!\n");
		exit(0);
	}
	
	int i, k;
	
	i = 0;
	k = 0;
	
	State * state;
	
	do
	{
		if (k < n)
		{
			for (i = 0; i < n; ++i)
			{
				state = CreateState(k, i);
				push(StateStack, state);
			}
		}
		
		state = pop(StateStack);
		k = state->k;
		i = state->i;
		board[k] = i;
		
		free(state);
		
		if (k == n - 1)
		{
			do
			{
				if (CheckBoard(board, n) == true)
				{
					Mark(board, n);
				}
				
				state = pop(StateStack);
				k = state->k;
				i = state->i;
				board[k] = i;
				
				free(state);
				
			} while (k == n-1);
		}
		
		++k;
		
	} while (CheckEmpty(StateStack) != true);
	
	DestroyStack(StateStack);
}
Exemple #15
0
/* This function generates a huffman coding tree using a stack implementation
   to keep track of the nodes.
   The paremeter is a file stream containing a huffman header at the top.
   The function will return the head of the binary tree, or it will print an
   error message and return NULL if the header file is incorrect. 
*/
LEAF* GenerateTree(FILE* fptr) {
   fseek(fptr, 0, SEEK_SET);
   char c;
   STACK_ELEMENT* stackHead = NULL;
   
   do {
      c = fgetc(fptr);
      if (c == '1') {
         LEAF* myLeaf = ConstructLeafNode(fgetc(fptr));
         /* Push the character to the stack as a new leaf node */
         stackHead = PushNodeToStack(stackHead, myLeaf);
      }
      else if (c == '0') {
         if (stackHead == NULL) {
            /* There should be something on the stack, break for error */
            break;
         }
         /* if the stack contains only one element, we have constructed the entire Huffman coding tree.
            This is the case where we want to return the fully constructed tree */
         else if (stackHead->next == NULL) {
            int numberOfCharacters;
            fscanf(fptr, "%d\n", &numberOfCharacters);
            LEAF* tree = stackHead->node;
            DestroyStack(stackHead);
            return tree;
         }
         /* This is the case where we want to combine the top two nodes off of the stack */
         else {
            LEAF* leafHead = ConstructLeafNode(NO_CHARACTER);
            /* First off the stack becomes the rchild of the new node */
            leafHead->rchild = stackHead->node;
            stackHead = PopFromStack(stackHead);
            /* Second off the stack becomes the lchild of the new node */
            leafHead->lchild = stackHead->node;
            stackHead = PopFromStack(stackHead);
            /* Push the new node on to the top in place of the two we just removed */
            stackHead = PushNodeToStack(stackHead, leafHead);
         }
      }
   } while (c != EOF || c != '\n');

   /* There is something wrong if we have arrived here */
   PrintError(INVALID_HEADER);
   return NULL;
}
Exemple #16
0
void LineEdit()
{
	char ch, c;
	SqStack s;

	InitStack(&s);
	ch = getchar();

	while (ch != EOF) {
		while ((ch != EOF) && (ch != '\n')) {
			switch (ch) {
			case '#':
				Pop(&s, &c);
				break;
			case '@':
				ClearStack(&s);
				break;
			default:
				Push(&s, ch);
				if (ch == EOF)
					printf("\n push eof\n");
				break;
			}
			ch = getchar();
		}
		// '\n' detected, send out and clear whole stack 
		if (ch == '\n') {
			StackTraverse(s, sendToFile);
			fputc('\n', fp);
			ClearStack(&s);
			ch = getchar();
		} else if (ch == EOF) {
			StackTraverse(s, sendToFile);
			ClearStack(&s);
			printf(" now exit\n");
		}
		/* if (ch == '\n') */
		/* 	fputc('\n', fp); */
		/* if (ch != EOF) */
		/* 	ch = getchar(); */
		/* else */
		/* 	printf("ch == eof, should exit\n"); */
	}
	DestroyStack(&s);
}
Exemple #17
0
int main()
{
	int i = 100;
	Stack st;
	InitStack(&st);

	while(i--)
	{
		Push(&st, i);
	}
	while(IsEmpty(&st))
	{
		printf("%d ", Top(&st));
		Pop(&st);
	}
	DestroyStack(&st);
	return 0;
}
 void main()
 {
   int j;
   LinkStack s;
   SElemType e;
   if(InitStack(&s))
     for(j=1;j<=5;j++)
       Push(s,2*j);
   printf("栈中的元素从栈底到栈顶依次为: ");
   StackTraverse(s,print);
   Pop(s,&e);
   printf("弹出的栈顶元素为%d\n",e);
   printf("栈空否: %d(1:空 0:否)\n",StackEmpty(s));
   GetTop(s,&e);
   printf("当前栈顶元素为%d,栈的长度为%d\n",e,StackLength(s));
   ClearStack(s);
   printf("清空栈后,栈空否: %d(1:空 0:否),栈的长度为%d\n",StackEmpty(s),StackLength(s));
   printf("是否销毁栈了: %d(1:是 0:否)\n",DestroyStack(&s));
 }
void testBasicStack() {
	SqStack S;
	InitStack(S);
	if (StackEmpty(S)) printf("the Stack S is Empty");
	PrintStack(S);
	printf("add item to the stack.\n");
	CreateStack(S);
	PrintStack(S);
	printf("pop the top of the stack:\n");
	ElemType e;
	Pop(S, e);
	PrintStack(S);
	printf("the element that is popped out: %d\n", e.key);
	ClearStack(S);
	printf("clear the stack:\n");
	PrintStack(S);
	printf("destroy the stack:\n");
	DestroyStack(S);
	PrintStack(S);
}
Exemple #20
0
void InOrderNotRecurssion(BiTree T)
{
   SqStack s;
   type p;
   s=StackInit(); p=T;
   while(p || !StackEmpty(s))
   {
      if(p)
      {
         s=Push(s,p); p=p->lchild;
      }
      else
      {
         s=Pop(s,&p);
         printf("%c ",p->data);
         p=p->rchild;
      }
   }
   printf("\n");
   DestroyStack(s);
}
Exemple #21
0
void Conversion(int num, int base) {
	SqStack stack;
	int i;
	int basenum[100];
	InitStack(&stack);
	for (i = 0; i < base; i++) {			//因为超过十进制就要用ABCD了
		if (i < 10)basenum[i] = '0' + i;	//所以用一个数组储存一张表,该表是该进制所用的符号集合
		else basenum[i] = 'A' + i - 10;
	}
	if (num == 0)printf("0\n");
	while (num) {
		Push(&stack, basenum[num%base]);	//把该进制所用的符号入栈,低数位先入栈,高位后入栈
		num /= base;
	}
	while (!StackEmpty(stack)) {
		Pop(&stack, &num);			//出栈并打印
		printf("%c", num);
	}
	printf("\n");
	DestroyStack(&stack);
}
Exemple #22
0
void ShutdownModernGLPatch(){
	if(vtx.vao_handle){
		if(vtx.p_pre_gl_buffer){
			glUnmapBuffer(GL_ARRAY_BUFFER);
			vtx.p_buffer_loc = 0;
			vtx.p_pre_gl_buffer = 0;
		}
		glDeleteVertexArrays(1, &vtx.vao_handle);		
		glDeleteBuffers(1,&vtx.vbo_handle);
		glDeleteBuffers(1,&vtx.transform_ubo_handle);
		glDeleteBuffers(1,&vtx.lighting_ubo_handle);
	}
	
	vtx.p_buffer_loc = 0;

	DeleteShaderProgram(&texture_shader);
	DeleteShaderProgram(&colour_shader);
	DeleteShaderProgram(&light_map_shader);
	glswShutdown();
	DestroyStack();
}
Exemple #23
0
void NonRecursive_Exchange(TreeNode* T)  
{  
 Stack s;  
 TreeNode* p;  
 if(NULL==T)  
  return;  
 InitStack(&s);  
 Push(&s,T);  
 while(!isEmpty(&s))  
 {  
  T = Pop(&s);  
  p = T->left;  
  T->left = T->right;  
  T->right = p;  
    
  if(T->right)  
   Push(&s,T->right);  
  if(T->left )  
   Push(&s,T->left );   
 }   
 DestroyStack(&s);   
} 
int main(){

	//tests
	Stack *s = CreateStack();
	Push(s,7);
	printf("pos %d\n",s->pos);
	printf("size %d\n",s->size);
	printf("pop %d\n",Pop(s));
	printf("pos %d\n",s->pos);
	printf("size %d\n",s->size);
	Push(s,8);
	Push(s,9);
	Push(s,10);
	printf("pop after push x3 %d\n",Pop(s));
	printf("pop %d\n",Pop(s));
	printf("pos %d\n",s->pos);
	printf("size %d\n",s->size);
	printf("pop %d\n",Pop(s));
	DestroyStack(s);

	return 0;
}
Exemple #25
0
int main()
{
	int cho;
	datatype e;
	LinkStack stack;
	InitStack(&stack);
	while(1)
	{
		printf("1.Push\n2.Pop\n3.Gettop\n4.Clear\n0.Exit\n");
		printf("Please input(0-4):");
		scanf("%d",&cho);
		switch(cho)
		{
			case 1:
				printf("Input data:");
				scanf("%d",&e);
				Push(stack,e);
				break;
			case 2:
				Pop(stack,&e);
				printf("%d\n",e);
				break;
			case 3:
				GetTop(stack,&e);
				printf("%d\n",e);
				break;
			case 4:
				DestroyStack(stack);
				break;
			case 0:
				exit(1);
			default:
				printf("Input error!\n");
				break;
		}
	}
	return 0;
}
int main(int argc, char *argv[])
{
	Stack stack;
	Element item;
	memset(&stack, 0x00, sizeof(Stack));

	item.key = 1;
	printf("Add 1st element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	item.key = 2;
	printf("Add 2nd element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	item.key = 3;
	printf("Add 3rd element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	item.key = 4;
	printf("Add 4th element into the stack. \n");
	AddStack(&stack, item);
	PrintStack(&stack);

	printf("Delete the top element from the stack. \n");
	item = DeleteStack(&stack);
	printf("Delete %d \n", item.key);

	PrintStack(&stack);

	printf("Destroy the stack. \n");
	DestroyStack(&stack);

	
	return 0;
}
Exemple #27
0
int main()
{
    int j;
    SqStack s;

    SElemType e;
    InitStack(&s);

    for(j=1; j<=12; j++)
    {
        Push(&s,j);
    }

    StackTraverse(s,print);
    Pop(&s,&e);

    StackTraverse(s,print);
    //GetTop(s,&e);

    //conversion(s);

    DestroyStack(&s);
}
Exemple #28
0
int main()
{
   SqStack S;
   if(InitStack(&S))
   {
       SElemType e;
       int i;

       printf("Init Success\n");

       if(IsEmpty(S))
       {
           printf("Stack is empty\n");
       }

       for(i = 0; i<10; i++)
       {
           Push(&S, i);
       }


       GetTop(S, &e);
       printf("The first element is %d\n",e);

       printf("Length is %d\n", GetLength(S));

       Pop(&S, &e);
       printf("Pop element is %d\n",e);

       TraverseStack(S, *visit);

       if(DestroyStack(&S))
       {
           printf("\nDestroy Stack Success\n");
       }
   }
}
Exemple #29
0
/*
*将中缀表达式转换为后缀表达式
*/
Status InfixToPostfix(char *infix,char *postfix)
{
    myStack s;
    ElemType c,temp;
    //int index=0,len,i=0,sum=0;
    InitStack(&s);

    do
    {
        c = *(infix++);
        if(c >= '0'&& c<= '9' )//如果是数字
        {
            *(postfix++) = c;
        }else
        {
            if((c == '(') || (c == '[') || (c == '{'))
            {
                Push(&s,c);
            }else if((c == ')') || (c == ']') || (c == '}'))
            {

                while(1)
                {
                    Pop(&s,&temp);
                    if(IsEmpty(&s) || (temp == '('))
                    {
                        break;
                    }
                    *(postfix++) = temp;
                }
            }
            else if((c == '+') || (c == '-') || (c == '*') || (c == '/') || (c == '%') || (c == '^'))
            {
                while(1)
                {
                    if(IsEmpty(&s))
                    {
                        Push(&s,c);
                        break;
                    }else
                    {
                        GetTopElement(&s,&temp);
                        if(GetPriority(temp) >= GetPriority(c))
                        {
                            Pop(&s,&temp);
                            *(postfix++) = temp;
                        }else
                        {
                            Push(&s,c);
                            break;
                        }
                    }
                }

            }else
            {
                printf("%c为非法输入!\n",c);
            }
        }
    }while( *infix != '\n');
    //将剩下的输出
    while(!IsEmpty(&s))
    {
        Pop(&s,&c);
        *(postfix++) = c;
    }
    DestroyStack(&s);
    return TRUE;
}
Exemple #30
0
int main(void)
{
	int select;		/*保存选择变量*/
	Elem e;			/*保存从函数返回的结点的值*/
	Elem v;			/*保存传递给函数的结点的值*/
	
	size_t i= 0;
	LINKSTACK S;
	InitStack(&S);	/*初始化栈*/

	srand((int)time(NULL));

	while (1)	/*while_@1*/
	{
		if (!(S.pBottom))
		{
			printf("栈不存在!\n");
			break;
		}

		system("cls");
		Menu();

		printf("请输入您的选择(1~9):");
		scanf("%d", &select);
		getchar();

		switch (select)	/*switch_@1*/
		{
		case 1:			/*入栈.*/
			v = InputValue("入栈元素为:");
			Push(&S, v);
			printf("入栈操作成功!\n");
			
			getchar();
			break;
		case 2:			/*输出栈中元素.*/
			printf("栈为:");
			TraveStack(&S);
			
			getchar();
			break;
		case 3:			/*出栈.*/
			if (OK == Pop(&S, &e))
			{
				printf("出栈成功,出栈元素是%d!\n", e);
			}
			else
			{
				printf("出栈失败!\n");
			}

			getchar();
			break;

		case 4:			/*输出栈的长度.*/
			printf("栈长为: %d \n", StackLength(&S));
			
			getchar();
			break;

		case 5:			/*清空栈.*/
			ClearStack(&S);
			printf("该栈已经清空!\n");
			
			getchar();
			break;
	
		case 6:			/*销毁栈.*/
			DestroyStack(&S);
			printf("栈已删除!\n");
			
			getchar();	
			break;
			
		case 7:			/*返回栈顶结点元素.*/
			if (OK == GetTop(&S, &e))
			{
				printf("栈顶为:%d\n", e);
			}
			else
			{
				printf("不存在栈顶元素!\n");
			}

			getchar();	
			break;

		case 8:			/*判断栈是否为空.*/
			if (StackEmpty(&S) == TRUE)
			{
				printf("栈为空!\n");
			}
			else
			{
				printf("栈非空!\n");
			}

			getchar();	
			break;

		case 9:			/*进制转换*/
			{
				int d;
				unsigned int m, n;
				v = InputValue("请输入一个非负整数:");
				d = InputValue("请输入转换进制:");
				if (v < 0 ||d<2 ||d>16)
				{
					printf("输入数据错误!\n");
					break;
				}
				
				m = (unsigned int)v;
				n = (unsigned int)d;
				Conversion_ten_to_n(m, n);
			
				getchar();
				break;
			}

		default:
			printf("请重新选择!\n");
			
			getchar();
			break;
		}/*switch_@1*/

	}	/*while_@1*/
	
	return EXIT_SUCCESS;
}