Created
September 16, 2017 15:01
-
-
Save invatainfo/fddd6d01a05fbdb897953e8947c310c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
int n, k, a[100]; | |
void f(int n, int a[100], int &k) { | |
k = 0; | |
int g = 0; | |
for (int i = n - 1; i >= 0; i--) | |
if (a[i] % 2 == 0) { | |
k = k * 10 + a[i]; | |
g++; | |
} | |
if (g == 0) | |
k = -1; | |
} | |
void main() { | |
cin >> n; | |
for (int i = 0; i < n; i++) | |
cin >> a[i]; | |
f(n, a, k); | |
cout << k; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment