diff --git a/elements.cpp b/elements.cpp deleted file mode 100644 index 56a27a9..0000000 --- a/elements.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include -using namespace std; - -int main() { - setlocale(0, ""); - srand(time(0)); - - const int SiZE = 15; - int arr[SiZE]; - - for (int i = 0; i < SiZE; i++) { - arr[i] = rand() % 21 - 10; - } - - cout << "Масив: "; - for (int i = 0; i < SiZE; i++) { - cout << arr[i] << " "; - } - cout << endl; - - int count = 0; - int third = 0; - bool found = false; - - for (int i = 0; i < SiZE; i++) { - if (arr[i] > 0) { - count++; - if (count == 3) { - third = arr[i]; - found = true; - break; - } - } - } - - int last = 0; - bool found2 = false; - - for (int i = SiZE - 1; i >= 0; i--) { - if (arr[i] < 0) { - last = arr[i]; - found2 = true; - break; - } - } - - if (found) { - cout << "Третiй додатний елемент: " << third << endl; - } - else { - cout << "Третiй додатний елемент не знайдено" << endl; - } - - if (found2) { - cout << "Останнiй вiд'ємний елемент: " << last << endl; - } - else { - cout << "Останнiй вiд'ємний елемент не знайдено" << endl; - } - - return 0; -}