public static BinNode<int> DeleteNode1 (BinNode<int> bnlist,BinNode<int> posDel)
bnlist = bnlist.GetRight();
BinNode<int> p1 = posDel.GetLeft();
BinNode<int> p2 = posDel.GetRight();
public static void DeleteNode (BinNode<int> bnlist,BinNode<int> posDel)
bnlist = bnlist.GetRight();
Console.WriteLine(bnlist.ToString());
BinNode<int> p1 = posDel.GetLeft();
BinNode<int> p2 = posDel.GetRight();
Console.WriteLine(bnlist.ToString());
public static BinNode<int> BuildBnlistInt ()
BinNode<int> duList = new BinNode<int> (int.Parse(Console.ReadLine()));
BinNode<int> last = duList;
int num = int.Parse(Console.ReadLine());
BinNode<int> p = new BinNode<int> (num);
num = int.Parse(Console.ReadLine());
public static BinNode<string> BuildBnlistStr ()
BinNode<string> duList = new BinNode<string> (Console.ReadLine());
BinNode<string> last = duList;
string num = Console.ReadLine();
BinNode<string> p = new BinNode<string> (num);
num = Console.ReadLine();
public static void PrintReverse (BinNode<int> bnlist)
Console.Write(p.GetValue()+" ");
Console.Write(p.GetValue()+" ");
public static void Show (Node<Student> lst)
Console.Write(pos.ToString());
public static void ShowBnlist (BinNode<int> lst)
Console.Write(pos.ToString());
public static BinNode<int> RemoveProduct (BinNode<int> bnlist,int product)
BinNode<int> posDel = bnlist;
while(posDel.HasRight() && posDel.GetValue()!=product)
posDel = posDel.GetRight();
bnlist = bnlist.GetRight();
BinNode<int> p1 = posDel.GetLeft();
BinNode<int> p2 = posDel.GetRight();
public static BinNode<string> RemoveProduct111 (BinNode<string> bnlist,string product)
if (product.Equals("") || bnlist==null)
Console.WriteLine("error");
BinNode<string> pos = bnlist;
while(pos.HasRight() && !pos.GetValue().Equals(product))
if (pos.GetValue().Equals(product) && pos==bnlist && !pos.HasRight())
else if (pos.GetValue().Equals(product) && pos==bnlist && pos.HasRight())
bnlist = bnlist.GetRight();
else if (pos.GetValue().Equals(product) && pos!=bnlist && pos.HasRight())
BinNode<string> p1 = pos.GetLeft();
BinNode<string> p2 = pos.GetRight();
else if (pos.GetValue().Equals(product) && pos!=bnlist && !pos.HasRight())
BinNode<string> temp = pos.GetLeft();
Console.WriteLine("error. the product does not exists");
public static void Main()
Console.WriteLine(t.ToString());
Console.WriteLine("min="+t.ShowMin());
Console.WriteLine("max="+t.GetMax());
Console.WriteLine(t.ToString());
Console.WriteLine(t.ExistX(3));
Console.WriteLine(t.IsExist7Boom());
private BinNode<int> bnlist;
public BinNode<int> GetBnlist ()
public void Insert (int x)
BinNode<int> tmp = this.bnlist;
bnlist = new BinNode<int>(x);
BinNode<int> p = new BinNode<int> (x);
if (x>this.max) this.max = x;
if (x<this.min) this.min = x;
BinNode<int> pos = bnlist;
BinNode<int> posDel = bnlist;
if (pos.GetValue() == this.max)
if (posDel==bnlist && bnlist!=null && !posDel.HasRight())
else if (posDel==bnlist && bnlist!=null && posDel.HasRight())
bnlist = bnlist.GetRight();
else if (posDel!=bnlist && posDel.HasRight())
BinNode<int> p1 = posDel.GetLeft();
BinNode<int> p2 = posDel.GetRight();
else if (posDel!=bnlist && !posDel.HasRight())
BinNode<int> temp = posDel.GetLeft();
public bool ExistX (int x)
BinNode<int> pos = bnlist;
public bool IsExist7Boom()
BinNode<int> pos = bnlist;
public override string ToString ()
BinNode<int> pos = this.bnlist;
txt = txt + pos.ToString();
txt = txt + "\n" + "min=" + this.min + ", max=" + this.max;
private BinNode<T> right;
public BinNode (BinNode<T> left, T x, BinNode<T> right)
public BinNode<T> GetLeft()
public BinNode<T> GetRight()
public void SetValue(T x)
public void SetLeft(BinNode<T> left)
public void SetRight(BinNode<T> right)
public override String ToString ()
private Node<Station> path;
public BusRoute (Station first, Station second)
this.path = new Node<Station> (second);
this.path = new Node<Station> (first,this.path);
public void AddStation (Station newStation)
Node<Station> pos = this.path;
p.SetNext(new Node<Station> (newStation));
public double RouteLength()
Node<Station> pos=this.path;
while (pos.GetNext()!=null)
len=len+pos.GetInfo().Distance(pos.GetNext().GetInfo());
public Node<Station> GetPath ()
public void SetPath (Node<Station> p)
public override String ToString()
string str=this.path.ToString();
Node<Station> pos=this.path.GetNext();
str = str+"-->"+pos.GetInfo().ToString();
public class BirthdaysSchool
private Node<Student> [] ar;
private const int SIZE = 6;
public BirthdaysSchool (Node<Student> [] ar)
public BirthdaysSchool ()
this.ar = new Node<Student>[SIZE];
this.ar[i] = new Node<Student> (new Student ());
public Node<Student>[] GetAr ()
public void SetAr (Node<Student>[] ar)
public override String ToString()
str=this.ar[i].ToString();
pos=this.ar[i].GetNext();
str = str+"-->"+pos.GetInfo().ToString();
text = text + str + "\n";
public Student (string name, Birth birthday)
this.birthDay=new Birth();
public Birth GetBirthDay ()
public void SetBirthDay (Birth birthDay)
this.birthDay = birthDay;
public void SetName (string name)
public override String ToString()
return "name = " + this.name + " birthday = " + this.birthDay.ToString();
public Birth (int day, int month, int year)
public void SetDay (int day)
public void SetMonth (int month)
public void SetYear (int year)
public override String ToString()
return this.day + "/" + this.month + "/" + this.year;
public Station (int x,int y)
public double Distance (Station other)
dis=Math.Sqrt(Math.Pow((double)(this.x-other.x), 2.0)+Math.Pow((double)(this.y-other.y), 2.0));
public override String ToString()
return "("+this.x+","+this.y+")";
this.first = new Node<int>(n);
this.first = new Node<int>(n);
this.first.SetNext(new Node<int>(n, first.GetNext()));
Node<int> pos = this.first;
public int Smallest(Collec c)
return Math.Min(Small(), c.Small());
public Node<int> GetFirst ()
public void SetFirst (Node<int> first)
public void SetMax (int max)
public override string ToString ()
Node<int> pos = this.first;
text = text + pos.ToString();
public Competitor (int minutes, int seconds, string name)
public bool IsFaster (Competitor c)
if ( (this.minutes*60 + this.seconds) < (c.minutes*60 + c.seconds) )
public void SetMinutes (int minutes)
public void SetSeconds (int seconds)
public void SetName (string name)
public override string ToString()
return "minutes = " + this.minutes + ", seconds = " + this.seconds + ", name = " + this.name + "\n";
private Node<Competitor> first;
public void Add (Competitor c)
Node<Competitor> pos = this.first;
Node<Competitor> prev = null;
while (pos!=null && pos.GetInfo().IsFaster(c))
this.first = new Node<Competitor>(c,this.first);
prev.SetNext(new Node<Competitor>(c,pos));
public string Rank (int x)
Node<Competitor> pos = this.first;
for (int i=1; pos!=null && i<x; i++)
return pos.GetInfo().GetName();
public Node<Competitor> GetFirst ()
public void SetFirst (Node<Competitor> first)
public override string ToString ()
Node<Competitor> pos = this.first;
text = text + pos.ToString();
public Node (T info, Node<T> next)
public void SetInfo(T info)
public void SetNext(Node<T> next)
return this.next != null;
public override String ToString()
private Node< BiStone > first;
this.first = new Node<BiStone> (new BiStone(0,0));
Node<BiStone> pos = first;
pos.SetNext(new Node<BiStone> (new BiStone(i,j)));
this.first = this.first.GetNext();
public Node<BiStone> GetFirst ()
public void SetFirst (Node<BiStone> first)
public override string ToString ()
Node<BiStone> pos = this.first;
text = text + pos.ToString();
public BiStone(int ones, int tens)
if (this.ones == (this.tens%10))
public void SetOnes (int ones)
public void SetTens (int tens)
public override string ToString()
return "ones digit = " + this.ones + ", tens digit = " + this.tens + "\n";