Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int noOfElements;
- cout << "Introduceti numarul de elemente: ";
- cin >> noOfElements;
- int *elements = new int[noOfElements];
- cout << "Introduceti elementele array-ului (doar 0 si 1) : " << endl;
- for (int i = 0; i < noOfElements; i++)
- {
- cout << "elements[" << i << "]= ";
- cin >> elements[i];
- }
- int no = 0;
- for (int i = 0; i < noOfElements; i++)
- {
- if (elements[i] == 1)
- {
- if (elements[i - 1] == 0 || elements[i + 1] == 0)
- {
- continue;
- }
- else
- {
- no++;
- }
- }
- }
- if (no == 0)
- {
- cout << "Da" << endl;
- }
- else
- {
- cout << "No" << endl;
- }
- delete[] elements;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement