For this program, I am NOT allowed to use an array orvector. These are the instr
ID: 3619335 • Letter: F
Question
For this program, I am NOT allowed to use an array orvector. These are the instructions for the program: You are given three data files that contain integer values.Each file has a different set of numbers. Each file has its set ofnumbers in sorted order (low to high). Write a program that willread the data for the three files and output one (1) file ofnumbers in sorted order. Example: file A, B, C FileA: 1 15 16 23 51 FileB: 0 91 101 122 130 FileC: 23 33 34 63 200 OutputFile: 0 1 15 16 23 32 33 34 51 63 91 101 122 130 200 Again, I cannot use an array or vector. For this program, I am NOT allowed to use an array orvector. These are the instructions for the program: You are given three data files that contain integer values.Each file has a different set of numbers. Each file has its set ofnumbers in sorted order (low to high). Write a program that willread the data for the three files and output one (1) file ofnumbers in sorted order. Example: file A, B, C FileA: 1 15 16 23 51 FileB: 0 91 101 122 130 FileC: 23 33 34 63 200 OutputFile: 0 1 15 16 23 32 33 34 51 63 91 101 122 130 200 Again, I cannot use an array or vector.Explanation / Answer
x.x.ce="Courier New" size="3"> #include #include #include using namespace std; void merge(fstream& in1, fstream& in2, fstream& out); int main() { fstream file1("A.txt"); fstream file2("B.txt"); fstream file3("C.txt"); fstream output("output.txt", ios::out); fstream temp("temp.txt", ios::out); merge(file1, file2, temp); temp.close(); fstream temp2("temp.txt"); merge(file3, temp2, output); // close files output.close(); file1.close(); file2.close(); file3.close(); // remove temp file remove("temp.txt"); return 0; } void merge(fstream& in1, fstream& in2, fstream& out) { int a, b; in1 >> a; in2 >> b; // dont add duplicates // intialize to value that is not a or b int last_out = -100000000; while(true) { if(aRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.