Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace AiSD1
- {
- class Program
- {
- public class Stec
- {
- int[] S = new int[100];
- int top = 0;
- public void PUSH(int x)
- {
- S[top] = x;
- top++;
- }
- public bool POP()
- {
- if (!ISEMPTY())
- {
- S[top - 1] = -1;
- return true;
- }
- else
- {
- return false;
- }
- }
- public bool ISEMPTY()
- {
- if (top == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public void CLAER()
- {
- int n = 0;
- while (S[n] != -1)
- {
- n++;
- S[n] = -1;
- }
- }
- public int TOP()
- {
- return S[top - 1];
- }
- }
- static void Main(string[] args)
- {
- Stec S = new Stec();
- S.PUSH(10);
- S.PUSH(10);
- S.PUSH(10);
- S.PUSH(10);
- S.POP();
- Console.WriteLine(S.TOP());
- S.CLAER();
- Console.WriteLine(S.ISEMPTY());
- Console.WriteLine("Hello World!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement