fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. int main()
  6. {
  7. std::map<std::string /*name*/, double /*value*/> vals;
  8. std::string cmd;
  9. while(std::cin >> cmd && cmd != "exit")
  10. {
  11. if(cmd == "store")
  12. {
  13. double v;
  14. std::string name;
  15. if(std::cin >> v >> name)
  16. {
  17. vals[name] = v;
  18. }
  19. }
  20. else if(cmd == "recall")
  21. {
  22. std::string name;
  23. if(std::cin >> name)
  24. {
  25. std::cout << vals[name] << std::endl;
  26. }
  27. }
  28. }
  29. }
Success #stdin #stdout 0s 3480KB
stdin
store 7 x
store 3 y
recall z
recall x
stdout
0
7