fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5.  
  6.  
  7.  
  8. int main()
  9. {
  10. std::vector<std::string> currentSet =
  11. {
  12. "HEAT",
  13. "COLD",
  14. "WARMTH",
  15. "COOLNESS",
  16. };
  17.  
  18. std::string input;
  19. std::getline(std::cin, input);
  20.  
  21. auto it = std::find(currentSet.begin(), currentSet.end(), input);
  22.  
  23. if (it == currentSet.end())
  24. std::cout << '"' << input << "\" was not found.\n";
  25. else
  26. std::cout << '"' << input << "\" was at index " << it - currentSet.begin() << " in currentSet\n";
  27. }
  28.  
Success #stdin #stdout 0s 3480KB
stdin
WARMTH
stdout
"WARMTH" was at index 2 in currentSet