Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*одн линам массив. вывести четные, отриц заменит на 0. потом нулевые заменить на полоусумму соседних*/
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, i;
- cout << "Input array size: "; cin >> n;
- int *mas = new int[n];
- for (i = 0; i < n; i++)
- {
- cout << "Input massive element " << i << ": "; cin >> mas[i];
- }
- cout << "The array is: " << endl;
- for (i = 0; i < n; i++) cout << mas[i] << "\t";
- cout << endl;
- //четные
- cout << "the array of tchetnye elements is:" << endl;
- for (i = 0; i < n; i++)
- {
- if (mas[i] % 2 == 0)
- cout << mas[i] << "\t";
- }
- cout << endl << "Otritsatelnye are zero:" << endl;
- for (i = 0; i < n; i++)
- {
- if (mas[i] % 2 == 0) {
- if (mas[i] < 0)
- mas[i] = 0;
- cout << mas[i] << "\t";
- }
- }
- cout << endl;
- for (i = 1; i < n-1; i++)
- if (mas[i] == 0) mas[i] = (mas[i - 1] + mas[i + 1]) / 2;
- for (i = 0; i < n; i++)
- {
- cout << mas[i] << "\t";
- }
- delete[]mas;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement