I've put together some sample code to approximate your task. It reads some integers from standard input, and throws it back to standard output. For your purposes, you may wish to format the output differently, and read/save it from/to a file at some point. There is probably more terse, more robust, more efficient, and prettier ways to do it, but I put this together quickly to get you started. If you find things that are strange to you, I would be happy to answer some questions, but the idea of this site is that you prove that you put some work into finding out the answers first (for example by visiting other questions, reading some books, or consulting the C++ reference at: https://en.cppreference.com/w/cpp)
#include <iostream>
#include <map>
#include <stdexcept>
using namespace std;
using MyMap = map<int, pair<int, int>>;
MyMap::value_type read_entry() {
int key, v_1, v_2;
bool started_read{false};
if ((cin >> key) && (started_read = true) && (cin >> v_1) && (cin >> v_2)) {
return {key, {v_1, v_2}};
} else if (started_read) {
throw invalid_argument("improper input");
} else {
return {};
}
}
MyMap read_map() {
MyMap myMap;
while (true) {
auto entry = read_entry();
if (cin) {
myMap.insert(move(entry));
} else if (cin.eof()) {
return myMap;
} else {
throw invalid_argument("io error");
}
}
}
void dump_map(const MyMap &myMap) {
for (auto &&value : myMap) {
cout << value.first << "\n"
<< value.second.first << "\n"
<< value.second.second << endl;
}
}
int main() {
cout << "reading map..." << endl;
MyMap myMap;
try {
myMap = read_map();
} catch (invalid_argument e) {
cout << "error encountered reading map: " << e.what() << endl;
return 1;
}
cout << "dumping map..." << endl;
dump_map(myMap);
}