fork download
  1. // Example program
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. int * arr;
  7. int len;
  8. cin >> len;
  9. arr = new int [len];
  10. for (int i = 0; i < len; i++) {
  11. cin >> arr[i];
  12. }
  13. for (int i = 0; i < len; i++) {
  14. if (arr[i] % 2 == 0 && i % 2 != 0) {
  15. cout << " first even element with odd index is : " << arr [i] << '[' <<i << ']' << endl;
  16. break;
  17. }
  18. }
  19. delete [] arr;
  20. }
  21.  
Success #stdin #stdout 0s 16064KB
stdin
10
1
2
3
4
5
6
7
8
9
10
stdout
 first even element with odd index is : 2[1]