What is the c++ code for Two-way sort/merge?


example;
how many input?:18 //it should be divisible by 3
input 18 numbers not in order(ascending):51 60 80 2 9 5 22 100 11 13 15 8 3 33 30 120 150 107

phase1 sort:
file1: 51 60 80| 11 22 100| 3 30 33| it will be in order and it will merge and sort with file 2.
file2: 2 5 9| 8 13 15| 107 120 150|
phase1 merge:
file1:empty
file2:empty
file3:2 5 9 51 60 80|8 11 13 15 22 100|3 30 33 107 120 150|
phase2 sort:
file1: 2 5 9 51 60 80(it will merge/sort with file 2:8 11 13 15 22 100) |3 30 33 107 120 150|
file2:8 11 13 15 22 100|

phase 2 merge:
file3:2 5 8 9 11 13 15 22 51 60 80 100 |3 30 33 107 120 150

phase3 sort:
file1:2 5 8 9 11 13 15 22 51 60 80 100 //it will merge and sort with file2
file2:3 30 33 107 120 150

phase3(final merge!);
file3:2 3 5 8 9 11 13 15 22 30 33 51 60 80 100 107 120 150
the numbers are sorted in ascending order
I don't think I've ever seen this board flooded with so many questions from one person at once. And it looks like a % of the questions are all about getting the last 2 digits out of a number.

Maybe you should delete a few of your topics and put them into one single topic.
And post some code to show some effort. I got an A in beginning and intermediate programming many many years ago -- since then I've moved on to harder problems.

Topic archived. No new replies allowed.