Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cout << "Enter the number of elements in the array: ";
- cin >> n;
- int* arr = new int[n]; // виділення пам'яті для масиву
- cout << "Enter the elements of the array:" << endl;
- for (int i = 0; i < n; i++) {
- cin >> *(arr + i); // введення елементів масиву
- }
- cout << "Even elements of the array: ";
- for (int i = 0; i < n; i++) {
- if (*(arr + i) % 2 == 0) { // перевірка на парність
- cout << *(arr + i) << " ";
- }
- }
- delete[] arr; // звільнення пам'яті
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement