fork download
  1. #include <iostream>
  2. # include <string>
  3.  
  4. int main()
  5. {
  6. std::cout << "What color do you want to search for?" << std::endl;
  7. std::string key;
  8. std::string ARRAY[5]={"green","gray","orange","red","blue"};
  9. std::cin >> key;
  10.  
  11. for (int i = 0; i < 5; i ++)
  12. {
  13. if (ARRAY[i] == key)
  14. {
  15. std::cout << "Found " << key << std::endl;
  16. break;
  17. }
  18. else
  19. std::cout << key << " not found" << std::endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3280KB
stdin
green
stdout
What color do you want to search for?
Found green