Queue using Struct
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace Structwithstackandqueue
{
class Program
{
struct StudentInfo
{
public string StdName;
public int StdID;
public Boolean StdGender;
}
static void Main(string[] args)
{
Queue<StudentInfo> StdQueue = new Queue<StudentInfo>();
StudentInfo T;
string C;
Boolean P;
do
{
[Link]();
[Link]("Welcome to this program");
[Link]("press A to add new data");
[Link]("press P to print all data");
[Link]("Press 1 to print the top element");
[Link]("Press C to know how many element in the queue");
[Link]("Press S to search for an elemet by the ID");
[Link]("Press R to remove the top element");
[Link]("Press 0 to remove all elements");
[Link]("Press x to quit");
C=[Link]();
switch ([Link]())
{
case "a": //adding element
[Link]("enter Student name:");
[Link] = [Link]();
[Link]("Enter the ID:");
[Link] = [Link]([Link]());
[Link]("Enter F for females or M for males: ");
[Link] = ([Link]().ToUpper() == "F") ? false : true;
[Link](T);
[Link]("\n\n\t\tDone");
break;
case "p": //printing all element
if ([Link] == 0)
[Link]("No element is found");
else
foreach (StudentInfo S in StdQueue)
[Link]([Link] + " " + [Link] + " " +
(([Link] == true) ? "male" : "female"));
break;
case "1": //printing the top element only
if ([Link] == 0)
[Link]("No element is found");
else
{
T = [Link]();
[Link]([Link] + " " + [Link] + " " + (([Link] ==
true) ? "male" : "female"));
}
break;
case "c":
[Link]("You have {0} element", [Link]());
break;
case "s":
[Link]("Please enter the ID you would like to search for:");
int N = [Link]([Link]());
P = false;
foreach (StudentInfo S in StdQueue)
{
if (N == [Link])
{
P = true;
[Link]([Link] + " " + [Link] + " " +
(([Link] == true) ? "male" : "female"));
}
}
if (P == false)
[Link]("No element is found with ID of "+N);
break;
case "r":
if ([Link] == 0)
[Link]("No element is found");
else
{
T = [Link]();
[Link]([Link] + "has been removed!");
}
break;
case "0":
if ([Link] == 0)
[Link]("No element is found");
else
{
[Link]();
[Link]("All elements have been removed!");
}
break;
case "x":
[Link](2000, 1000);
[Link]("See you later!");
break;
}
[Link]();
} while ([Link]() != "x");
[Link]();
}
}
}