using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace VDQueue
{
class Node
{
public char value;
public Node next;
}
class Queue
{
public Node first;
public bool EmptyQueue()
{
return first == null;
}
public void EnQueue(char x)
{
Node tg = new Node();
tg.value = x;
tg.next = first;
first = tg;
}
public char DeQueue()
{
char value;
if (first == null) throw new Exception("Queue empty");
{
if (first.next == null)
{
value = first.value;
first = null;
}
else
{
Node c = first;
while (c.next.next != null) c = c.next;
value = c.next.value;
c.next = null;
}
return value;
}
}
public void Cleanup()
{
first = null;
}
public char Front()
{
char value;
if (first == null) throw new Exception("Queue empty");
{
if (first.next == null)
{
value = first.value;
}
else
{
Node c = first;
while (c.next.next != null) c = c.next;
value = c.next.value;
}
return value;
}
}
}
class Phuc
{
static void Main()
{
Queue t = new Queue();
string x;
Console.Write("Nhap chuoi ky tu:");
x = Console.ReadLine();
for (int i = 0; i < x.Length; i++)
{
t.EnQueue(x[i]);
}
char s;
Console.WriteLine("Ket qua:");
while (!t.EmptyQueue())
{
s = t.DeQueue();
if ((int)s >= (int)'a' && (int)s <= (int)'z') Console.Write(s);
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace VDQueue
{
class Node
{
public char value;
public Node next;
}
class Queue
{
public Node first;
public bool EmptyQueue()
{
return first == null;
}
public void EnQueue(char x)
{
Node tg = new Node();
tg.value = x;
tg.next = first;
first = tg;
}
public char DeQueue()
{
char value;
if (first == null) throw new Exception("Queue empty");
{
if (first.next == null)
{
value = first.value;
first = null;
}
else
{
Node c = first;
while (c.next.next != null) c = c.next;
value = c.next.value;
c.next = null;
}
return value;
}
}
public void Cleanup()
{
first = null;
}
public char Front()
{
char value;
if (first == null) throw new Exception("Queue empty");
{
if (first.next == null)
{
value = first.value;
}
else
{
Node c = first;
while (c.next.next != null) c = c.next;
value = c.next.value;
}
return value;
}
}
}
class Phuc
{
static void Main()
{
Queue t = new Queue();
string x;
Console.Write("Nhap chuoi ky tu:");
x = Console.ReadLine();
for (int i = 0; i < x.Length; i++)
{
t.EnQueue(x[i]);
}
char s;
Console.WriteLine("Ket qua:");
while (!t.EmptyQueue())
{
s = t.DeQueue();
if ((int)s >= (int)'a' && (int)s <= (int)'z') Console.Write(s);
}
Console.ReadKey();
}
}
}