fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. //The GOAT ^_^
  6. int main() {
  7. int n; cin >> n;
  8. int arr[n];
  9.  
  10.  
  11. for (int i = 0; i < n; i++) {
  12. cin >> arr[i];
  13. }
  14.  
  15. //print evens
  16. for (int i = 0; i < n; i++) {
  17. if (arr[i] % 2 == 0) cout << arr[i] << ' ';
  18. }
  19.  
  20. cout << '\n';
  21. //print odds
  22. for (int i = 0; i < n; i++) {
  23. if (arr[i] % 2 != 0) cout << arr[i] << ' ';
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5272KB
stdin
5
1 2 3 4 5
stdout
2 4 
1 3 5