fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. constexpr int N = 10;
  5.  
  6. int a[N] = { 1,2,3,4,5,6,7,8,9,0 };
  7. int b[N] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
  8. int c[N];
  9.  
  10. void printArray(int* a, int length) {
  11. for (int i = 0; i < length; ++i) {
  12. cout << a[i] << "\t";
  13. }
  14. cout << endl;
  15. }
  16.  
  17. int main() {
  18. // your code goes here
  19. for (int i = 0; i < N; ++i)
  20. c[i] = (i%2 == 0 ? a[i+1] : b[i-1]);
  21.  
  22. printArray(a, N);
  23. printArray(b, N);
  24. printArray(c, N);
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1	2	3	4	5	6	7	8	9	0	
10	11	12	13	14	15	16	17	18	19	
2	10	4	12	6	14	8	16	0	18