fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6. cin >> N;
  7.  
  8. long long a[1000];
  9. for (int i = 0; i < N; ++i) cin >> a[i];
  10.  
  11. int K = 0;
  12. for (int i = N - 1; i >= 0; --i)
  13. if (a[i] % 2 != 0) {
  14. if (K) cout << ' ';
  15. cout << a[i];
  16. ++K;
  17. }
  18.  
  19. if (K) cout << '\n';
  20. cout << K << '\n';
  21. }
Success #stdin #stdout 0s 5324KB
stdin
5 15 76 89 43 2
stdout
43 89 15
3