using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp18
{
interface ASiD
{
void Push();
void Pop();
void Length();
void Show();
}
class Kolejka : ASiD
{
int[] tablica = new int[16];
int ile=0;
int pocz=0;
int kon=0;
public void Push()
{
if (ile>=16)
{
Console.WriteLine("Kolejka jest pelna");
}
else
{
Console.WriteLine("Jaką liczbę wstawić do kolejki? ");
tablica[kon]= Convert.ToInt32(Console.ReadLine());
kon++;
ile++;
}
}
public void Pop()
{
if (ile==0)
{
Console.WriteLine("Kolejka jest pusta");
}
else
{
Console.WriteLine("Usunięcie z kolejki liczby: " + tablica[pocz]);
pocz++;
ile--;
}
}
public void Length()
{
Console.WriteLine("Liczba elementow w kolejce: " + ile);
}
public void Show()
{
Console.WriteLine("Zawartość kolejki: ");
if (ile==0)
{
Console.WriteLine("Kolejka jest pusta");
}
else
{
int indeks;
for (int i=0; i<ile; i++)
{
indeks = pocz + i;
Console.WriteLine(tablica[indeks]);
}
}
}
}
class Stos : ASiD
{
int[] tablica = new int[16];
int rozmiar=0;
public void Push()
{
if (rozmiar>=16)
{
Console.WriteLine("Stos pełny");
}
else
{
Console.WriteLine("Jaką liczbę wstawić do stosu? ");
tablica[rozmiar] = Convert.ToInt32(Console.ReadLine());
rozmiar++;
}
}
public void Pop()
{
if(rozmiar>=1)
{
Console.WriteLine("Usunięcie liczby ze stosu" );
rozmiar--;
}
else
{
Console.WriteLine("Stos pusty");
}
}
public void Length()
{
Console.WriteLine("Liczba elementow w stosie: " + rozmiar);
}
public void Show()
{
Console.WriteLine("Zawartość stosu: ");
if (rozmiar == 0)
{
Console.WriteLine("Stos jest pusty");
}
else
{
int indeks;
for (int i = 0; i < rozmiar; i++)
{
indeks = i;
Console.WriteLine(tablica[indeks]);
}
}
}
}
class Program
{
static void Main(string[] args)
{
Kolejka kolejka = new Kolejka();
Stos stos = new Stos();
stos.Show();
stos.Push();
stos.Push();
stos.Push();
stos.Show();
stos.Pop();
stos.Show();
stos.Push();
stos.Push();
stos.Push();
stos.Show();
stos.Pop();
stos.Pop();
stos.Show();
stos.Length();
Console.ReadKey();
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}