fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, x;
  6. cin >> n >> x;
  7. int firstEven, lastEven;
  8. bool firstFound = false;
  9. for (int i = 1; i <= n; ++i) {
  10. int currentNum;
  11. cin >> currentNum;
  12. if (currentNum % 2 == 0) {
  13. lastEven = currentNum;
  14. if (firstFound == false) {
  15. firstEven = currentNum;
  16. firstFound = true;
  17. }
  18. }
  19. }
  20. cout << firstEven << ' ' << lastEven;
  21. return 0;
  22. }
Success #stdin #stdout 0s 5284KB
stdin
5 4
2 2
stdout
2 2