fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int oddNo = -1, evenNo = -1, currentNo;
  8. for (int i = 1; i <= n; ++i) {
  9. cin >> currentNo;
  10. if (currentNo % 2 == 0) {
  11. if (evenNo == -1) {
  12. evenNo = currentNo;
  13. }
  14. } else {
  15. oddNo = currentNo;
  16. }
  17. }
  18. cout << evenNo << " " << oddNo;
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5264KB
stdin
4
1 3 5 8
stdout
8 5