fork download
  1. #include <iostream>
  2. #include <initializer_list>
  3. #include <algorithm>
  4.  
  5. int main() {
  6.  
  7. int x = 7;
  8.  
  9. if (const auto a = {1,2,4,6,7}; a.end() != std::find(a.begin(), a.end(), x) )
  10. std::cout << "x is either 1,2,4,6 or 7" << std::endl;
  11. else
  12. std::cout << "x is something else" << std::endl;
  13.  
  14. // your code goes here
  15. return 0;
  16. }
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
x is either 1,2,4,6 or 7