⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stack.c

📁 Stack, queue, sorting exmaples in C/C++.
💻 C
字号:
#include<stdio.h>
#include<conio.h>
#include<iostream.h>

struct stack{
  int top;
  int item[30];
   };

void push( struct stack *p)
{  int i;
   if(p->top==5)
   {
     printf("stack full");
     for(i=0;i<5;i++)
      { printf("%d",p->item[i]);
	 }
      }

else
  {
  int h;
  printf("enter the char");
  scanf("%d",&h);

   p->item[p->top]=h;
   p->top++;
   printf("%d has been added\n",h);
 }
      }

void pop(struct stack *p)
{
 int x;
 if(p->top==0)
 printf("stack empty");
 else
{
 p->top--;
 x=p->item[p->top];
 printf("%d has been poped",x);

 }
}
void main()
{
 struct stack *w;
 int i;
 w->top=0;

 printf("enter 1 p 2 pus 3 exi\n");
 scanf("%d",&i);
 while(i!=3)
 {
  switch (i)
  {
   case 1:
   pop(w);
   break;

   case 2:
   push(w);
   break;

   }
   printf("enter nos");
   scanf("%d",&i);
}   }





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -