fork(2) download
  1. #include <iostream>
  2. #include <cassert>
  3.  
  4. int main()
  5. {
  6. constexpr int N = 5 ;
  7. constexpr int a[N] = { 1, 2, 3, 4, 5 } ;
  8. constexpr int b[N] = { 2, 9, 8, 0, 7 } ;
  9.  
  10. const auto isdigit = [] ( int v ) { return v >= 0 && v < 10 ; } ;
  11. int sum = 0 ;
  12. for( int i = 0 ; i < N ; ++i )
  13. {
  14. assert( isdigit( a[i] ) && isdigit( b[i] ) ) ;
  15. sum *= 10 ;
  16. sum += a[i] + b[i] ;
  17. }
  18. std::cout << sum << '\n' ;
  19. }
  20.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
42152