system.collection.stack
system.collection.genericclass Program {
static void Main(string[] args)
{
StackX stack = new StackX(10);
stack.Push(5);
stack.Push(1);
stack.Push(3);
stack.Push(6);
stack.Push(9);
Console.WriteLine("现在的元素是:");
stack.Display();
stack.Pop();
stack.Pop(2);
Console.WriteLine("操作之后的元素是:");
stack.Display();
Console.ReadLine();
} static void StartMethod()
{
Console.WriteLine("start.....");
for (int i = 10; i < 20; i++)
{
Thread.Sleep(100);
//Console.WriteLine(i.ToString());
}
Console.WriteLine("end.....");
}
}using System;
using System.Collections.Generic;
using System.Text;namespace ConApp1
{
class StackX
{
private int [] stackx;
private int maxSize;
private int top; public StackX(int max)
{
stackx = new int[max];
maxSize = max;
top = 0;
} public int Len
{
get
{
return stackx.Length;
}
} public int MaxSize
{
get
{
return maxSize;
}
} public bool IsEmpty()
{
return (top == 0);
} public bool IsFull()
{
return (top == maxSize);
} public bool Push(int intdata)
{
if (top == maxSize)
{
Console.WriteLine("The Stack is Full.........");
return true;
}
stackx[++top] = intdata;
return true;
} public int Pop()
{
if (top == 0)
{
Console.WriteLine("The Stack is Empty.........");
return 0;
}
return stackx[top--];
} public bool Pop(int num)
{
if (top == 0)
{
Console.WriteLine("The Stack is Empty.........");
return false;
}
top = top - num;
return true;
} public int Peek()
{
if (top == 0)
{
Console.WriteLine("The Stack is Empty.........");
return 0;
}
return stackx[top];
} public void Display()
{
for (int i = 0; i < top+1; i++)
{
Console.WriteLine("第"+(i+1)+"个元素是: "+stackx[i].ToString());
}
}
}
}
system.collection.genericclass Program {
static void Main(string[] args)
{
StackX stack = new StackX(10);
stack.Push(5);
stack.Push(1);
stack.Push(3);
stack.Push(6);
stack.Push(9);
Console.WriteLine("现在的元素是:");
stack.Display();
stack.Pop();
stack.Pop(2);
Console.WriteLine("操作之后的元素是:");
stack.Display();
Console.ReadLine();
} static void StartMethod()
{
Console.WriteLine("start.....");
for (int i = 10; i < 20; i++)
{
Thread.Sleep(100);
//Console.WriteLine(i.ToString());
}
Console.WriteLine("end.....");
}
}using System;
using System.Collections.Generic;
using System.Text;namespace ConApp1
{
class StackX
{
private int [] stackx;
private int maxSize;
private int top; public StackX(int max)
{
stackx = new int[max];
maxSize = max;
top = 0;
} public int Len
{
get
{
return stackx.Length;
}
} public int MaxSize
{
get
{
return maxSize;
}
} public bool IsEmpty()
{
return (top == 0);
} public bool IsFull()
{
return (top == maxSize);
} public bool Push(int intdata)
{
if (top == maxSize)
{
Console.WriteLine("The Stack is Full.........");
return true;
}
stackx[++top] = intdata;
return true;
} public int Pop()
{
if (top == 0)
{
Console.WriteLine("The Stack is Empty.........");
return 0;
}
return stackx[top--];
} public bool Pop(int num)
{
if (top == 0)
{
Console.WriteLine("The Stack is Empty.........");
return false;
}
top = top - num;
return true;
} public int Peek()
{
if (top == 0)
{
Console.WriteLine("The Stack is Empty.........");
return 0;
}
return stackx[top];
} public void Display()
{
for (int i = 0; i < top+1; i++)
{
Console.WriteLine("第"+(i+1)+"个元素是: "+stackx[i].ToString());
}
}
}
}
stack.Push("in String");