我知道外部合并排序及其工作原理。但目前我在实施它时遇到了困难。我已经编写了对数组进行排序和合并的代码,但是在从文件中读取数据和将数据写入文件时遇到了问题,我想在 C++ 中实现以下方法:
1. int * read(int s, int e) : This method should read from file all the number
starting from 's' till 'e' and return the array
2. write(int a[], int s, int e) : This method should write to file the input
array by replacing the numbers from s to e.
例如。
Given file has the following numbers:
1
2
3
4
5
6
read(0, 2) should return [1,2,3]
write([4,5,6], 0, 2) should update the file to :
4
5
6
4
5
6
如何实现这两种方法?