``` #include <iostream> #include <fstream> #include <algorithm> class bindata { private: int data[20]; public: bindata(const char* filename = "") { if (filename[0] != '\0') { std::ifstream file(filename, std::ios::binary); if (file.is_open()) { file.read((char*)data, sizeof(int) * 10); } } } bindata operator+(const bindata& other) const { bindata result; std::merge(data, data + 10, other.data, other.data + 10, result.data, std::greater<int>()); return result; } friend bool operator>(const bindata& lhs, const bindata& rhs) { return std::lexicographical_compare(lhs.data, lhs.data + 20, rhs.data, rhs.data + 20, std::greater<int>()); } void sort() { std::sort(data, data + 20, std::greater<int>()); } void print() { for (int i = 0; i < 20; i++) { std::cout << data[i] << " "; } std::cout << std::endl; } }; int main() { bindata bina("c:lisy13la.bin"); bindata binb("c:ilsy131nb.bin"); bina.sort(); binb.sort(); bindata binab = bina + binb; binab.print(); return 0; } ``` [2024-06-01 16:29:51 | AI写代码神器 | 811点数解答]