Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- void cycle (int *a, int n)
- {
- //Замена соседних с единицей
- for (int i = 0; i < n; i++)
- {
- if (a[i] == 1)
- {
- a[i - 1] = 0;
- a[i + 1] = 0;
- }
- }
- //Вывод массива
- for (int i = 0; i < n; i++)
- {
- cout << a[i];
- }
- cout << endl;
- }
- int main()
- {
- //Выделение памяти
- int *a,n;
- cout << " Enter Size - "; cin >> n;
- a = new int[n];
- //Ввод массива
- int i;
- for (i = 0; i < n; i++)
- {
- cout << "a[" << i << "] = "; cin >> a[i];
- }
- //Вызов функции
- cycle(a, n);
- //Освобождение памяти
- delete[]a;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement