fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8.  
  9. int x;
  10. string z = "";
  11. string a = "";
  12.  
  13. for (int i = 0; i < n; ++i) {
  14. cin >> x;
  15. if (i % 2 == 0) {
  16. z += to_string(x) + " ";
  17. } else {
  18. a += to_string(x) + " ";
  19. }
  20. }
  21.  
  22. cout << z << endl;
  23. cout << a << endl;
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
1 2 3 4 5
stdout
1 3 5 
2 4