public int[] SortMain(int arr1Length, int[] arr2) { int x1; int x2; for (int i = 0; i < arr1Length - 1; i++) { Bubble.printArray(arr2); if (arr2[i] > arr2[i + 1]) { x1 = arr2[i]; x2 = arr2[i + 1]; arr2[i] = x2; arr2[i + 1] = x1; } } Bubble.printArray(arr2); return(arr2); }
static void Main(string[] args) { int n = 0; //int nn; BS a; Bubble bubble; Employee[] employees; //int[] num; //double average; string filename; string query; // catch missing arguments error. try { filename = args[0]; query = args[1]; // catch file not found exception. try { var sr = new StreamReader(filename); //var sr2 = new StreamReader(query); //nn = int.Parse(sr2.ReadLine()); n = int.Parse(sr.ReadLine()); employees = new Employee[n]; //num = new int[nn]; a = new BS(); bubble = new Bubble(); average = 0; // reading Employee information by for loop for (int i = 0; i < n; i++) { string nextLine = sr.ReadLine(); employees[i] = new Employee(nextLine); } // reading query //for (int i = 0; i < nn; i++) //{ // int nl = int.Parse(sr2.ReadLine()); // num[i] = nl; //} //sequential search //foreach (int j in num) //{ // var result = a.BinarySearch(j, employees, 0, employees.Count()); // Console.WriteLine("Looking for " + j + " ... Found " + employees[result.Item1].name + " at position " + result.Item1 + " after " + result.Item2 + " comparisons."); // average += result.Item2; //} //Console.WriteLine("Average number of comparisons overall : " + average / nn); sr2.Close(); sr.Close(); } catch (FileNotFoundException e) { Console.WriteLine("File has not found."); } } catch (IndexOutOfRangeException asa) { Console.WriteLine("Missing argument line"); } }