Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. int n;
  8. cout << "N vector elements ";
  9. cout << endl;
  10. cout << "n = ";
  11. cin >> n;
  12.  
  13. int a[20], b[20];
  14.  
  15. for (int i = 0; i < n; i++) {
  16.  
  17. cout << "a[" << i << "] = ";
  18. cin >> a[i];
  19.  
  20. }
  21. cout << endl;
  22.  
  23. int j = 0;
  24.  
  25. for (int i = 0; i < n; i++) {
  26.  
  27. if (a[i] / 2 == 0)
  28. b[j++] = a[i];
  29. }
  30.  
  31. for (int i = 0; i < n; i++) {
  32. cout << b[i] << " ";
  33. }
  34.  
  35.  
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement