// // Author: SUZUKI, RICARDO // Merge sort program // last update on Saturday, April 26 #include #include #include #include using namespace std; int Many_int(); //PRECONDITION: there must be a .txt file with int //POSTCONDITIN: returns the amount of int in the file void fill_up_array(int array[]); //PRECONDITION: receives an array //POSTCONDITIN: fill it up with the numbers from // the .txt file void mergesort(int array[], int size); //PRECONDITION: receives the array and its size //POSTCONDITIN: sorts the array void print(int array[], int size); //PRECONDITION: receives the array and its size //POSTCONDITIN: print the array void main() { int dummy=0; int many_numbers = Many_int(); int *array_to_merge; array_to_merge = new int[many_numbers]; fill_up_array(array_to_merge); // call the sort function mergesort(array_to_merge, many_numbers); print(array_to_merge, many_numbers); } void print(int array[], int size) { ofstream outfile; outfile.open("output.txt"); outfile<<" Merge Sort"<>dummy; array[i] = dummy; i++; } fill_array.close(); } // counts how many numbers in the file int Many_int() { ifstream count_file; count_file.open("input.txt"); if(!count_file) { cout<<"There is no file to read"<>dummy; many_numbers++; } --many_numbers; count_file.close(); return many_numbers; }