fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <vector>
  5.  
  6. int main() {
  7.  
  8. std::map<std::pair<int, int>, std::string> mymap;
  9. for(int i = 0; i < 10; i = i + 2) {
  10. std::pair<int, int> temp;
  11. temp.first = i;
  12. temp.second = i+1;
  13. std::string temp2;
  14. std::cout << "Enter a string: ";
  15. std::cin >> temp2;
  16. mymap[temp] = temp2;
  17. }
  18.  
  19. int count =0;
  20. while(count++ != 3) {
  21. int temp, temp2;
  22. std::cout << "Enter a number: ";
  23. std::cin >> temp;
  24. std::cout << "Enter another number: ";
  25. std::cin >> temp2;
  26.  
  27. std::pair<int, int> test;
  28. test.first = temp;
  29. test.second = temp2;
  30. std::cout << mymap[test] << std::endl;
  31. }
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3436KB
stdin
quick
brown
fox
jumps
over
0 1
4 5
8 9
stdout
Enter a string: Enter a string: Enter a string: Enter a string: Enter a string: Enter a number: Enter another number: quick
Enter a number: Enter another number: fox
Enter a number: Enter another number: over