fork download
  1. #include <iostream>
  2.  
  3. void do_math( const int (&a)[3] )
  4. {
  5. std::cout << "do_math -" ;
  6. for( int v : a ) std::cout << ' ' << v ;
  7. std::cout << '\n' ;
  8. }
  9.  
  10. int main()
  11. {
  12. constexpr int constants[][3] = { {}, {0,1,2}, {4,5,6}, {7,8,9}, {10,11,12} } ;
  13. constexpr std::size_t n = sizeof(constants) / sizeof(*constants) ;
  14.  
  15. std::size_t ans ; std::cout << "please enter number: " && std::cin >> ans ;
  16. if( ans>0 && ans<n ) do_math( constants[ans] ) ;
  17. }
  18.  
Success #stdin #stdout 0s 2856KB
stdin
3
stdout
please enter number: do_math - 7 8 9