Write a program that merges the numbers in two files and writes all the numbers into a third file.Each input list contains a list of numbers of type int in sorted order from the smallest to the largest.After running this program,then the new list should contain the all the numbers in the two input files and in sorted from smallest to largest.We must use a function which contains two input-file streams and one output-file stream.
I ask my professor to give me some hint,he told me like this:
since a1<a2<......,b1<b2<.....,so we just compare a1 and b1,if a1<b1 then write a1 to the third list,then compare a2 and b1.
It sounds that it is a very easy problem,but how to apply this?
I think we can do this:
but how to do compare a2 with b1(or b2 with a1)?we use two arrays to store these numbers?
At first,I think we can do this:first input all the two lists into the third file,so we have a new
total list which contains the whole numbers,then sort only this list,of course it will be a bad
program since it will cost more time to finish the task.
So how to do?