Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:01
Show Gist options
  • Save invatainfo/fddd6d01a05fbdb897953e8947c310c5 to your computer and use it in GitHub Desktop.
Save invatainfo/fddd6d01a05fbdb897953e8947c310c5 to your computer and use it in GitHub Desktop.
#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