public static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine("Enter Length:"); int i = Convert.ToInt32(Console.ReadLine()); WeightedQuickUnionUF wquf = new WeightedQuickUnionUF(i); int choice = 1; while (choice != 3) { Console.WriteLine("Select operation"); Console.WriteLine("1. Add Connection"); Console.WriteLine("2. Check Connection"); Console.WriteLine("3. Exit"); Console.WriteLine("Enter your choice"); choice = Convert.ToInt16(Console.ReadLine()); int p = 0; int q = 0; if (choice != 3) { Console.WriteLine("Add / Check connection between two points - select between 0 and " + (i - 1).ToString()); Console.WriteLine("Enter point p "); p = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("Enter point q "); q = Convert.ToInt16(Console.ReadLine()); } switch (choice) { case 1: wquf.union(p, q); break; case 2: bool b = wquf.connected(p, q); Console.WriteLine("Are both points connected ?"); Console.WriteLine(b.ToString()); break; default: break; } } Console.ReadLine(); }
public static void Main (string[] args) { Console.WriteLine ("Hello World!"); Console.WriteLine ("Enter Length:"); int i = Convert.ToInt32(Console.ReadLine()); WeightedQuickUnionUF wquf = new WeightedQuickUnionUF (i); int choice = 1; while (choice != 3) { Console.WriteLine ("Select operation"); Console.WriteLine ("1. Add Connection"); Console.WriteLine ("2. Check Connection"); Console.WriteLine ("3. Exit"); Console.WriteLine ("Enter your choice"); choice = Convert.ToInt16 (Console.ReadLine ()); int p = 0 ; int q = 0 ; if (choice != 3) { Console.WriteLine ("Add / Check connection between two points - select between 0 and " + (i - 1).ToString ()); Console.WriteLine ("Enter point p "); p = Convert.ToInt16 (Console.ReadLine ()); Console.WriteLine ("Enter point q "); q = Convert.ToInt16 (Console.ReadLine ()); } switch (choice) { case 1: wquf.union (p, q); break; case 2: bool b = wquf.connected (p, q); Console.WriteLine ("Are both points connected ?"); Console.WriteLine (b.ToString ()); break; default: break; } } Console.ReadLine (); }