c++ map change order

#include <iostream>
#include <map>

int main() {
    std::map<int, int> myMap;

    myMap[4] = 40;
    myMap[1] = 10;
    myMap[6] = 60;
    myMap[3] = 30;
    myMap[2] = 20;
    myMap[5] = 50;

    std::cout << "Original order:" << std::endl;
    for (const auto& pair : myMap) {
        std::cout << pair.first << " => " << pair.second << std::endl;
    }

    std::map<int, int> reorderedMap;

    for (const auto& pair : myMap) {
        reorderedMap[pair.first * 2] = pair.second;
    }

    std::cout << "\nReordered map by multiplying keys by 2:" << std::endl;
    for (const auto& pair : reorderedMap) {
        std::cout << pair.first << " => " << pair.second << std::endl;
    }

    return 0;
}
  1. Included necessary header files.
  2. Defined the main() function.
  3. Created an empty std::map<int, int> called myMap.
  4. Added key-value pairs to myMap in arbitrary order: (4, 40), (1, 10), (6, 60), (3, 30), (2, 20), (5, 50).
  5. Printed the original order of myMap.
  6. Created an empty std::map<int, int> named reorderedMap.
  7. Iterated through myMap and multiplied each key by 2 and stored the result along with the corresponding value in reorderedMap.
  8. Printed the contents of reorderedMap after reordering the keys by multiplying them by 2.
  9. Terminated the program.