From 729e9a7503263a9b9bd9e18a4f5af110825cc4a6 Mon Sep 17 00:00:00 2001 From: Misha Date: Thu, 18 Sep 2025 19:34:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profit_analysis.cpp | 48 +++++++++++++ range_checker.cpp | 37 ++++++++++ remove_digits.cpp | 29 ++++++++ sum_calculator.cpp | 24 +++++++ task2.cpp | 168 +++++++++++++++++++++----------------------- 5 files changed, 220 insertions(+), 86 deletions(-) create mode 100644 profit_analysis.cpp create mode 100644 range_checker.cpp create mode 100644 remove_digits.cpp create mode 100644 sum_calculator.cpp diff --git a/profit_analysis.cpp b/profit_analysis.cpp new file mode 100644 index 0000000..e77b819 --- /dev/null +++ b/profit_analysis.cpp @@ -0,0 +1,48 @@ +#include +using namespace std; + +int main() { + setlocale(0, ""); + double profit[12]; + + const char* months[12] = { + "Сiчень", "Лютий", "Березень", "Квiтень", + "Травень", "Червень", "Липень", "Серпень", + "Вересень", "Жовтень", "Листопад", "Грудень" + }; + + cout << "Введiть прибуток фiрми за кожен мiсяць року:" << endl; + + for (int i = 0; i < 12; i++) { + cout << months[i] << ": "; + cin >> profit[i]; + } + + int maxIndex = 0; + for (int i = 1; i < 12; i++) { + if (profit[i] > profit[maxIndex]) { + maxIndex = i; + } + } + + int minIndex = 0; + for (int i = 1; i < 12; i++) { + if (profit[i] < profit[minIndex]) { + minIndex = i; + } + } + + double totalSum = 0; + for (int i = 0; i < 12; i++) { + totalSum += profit[i]; + } + + cout << "\nРезультати аналiзу:" << endl; + cout << "Мiсяць з максимальним прибутком: " << months[maxIndex] + << " (прибуток: " << profit[maxIndex] << ")" << endl; + cout << "Мiсяць з мiнiмальним прибутком: " << months[minIndex] + << " (прибуток: " << profit[minIndex] << ")" << endl; + cout << "Загальна сума прибутку за рiк: " << totalSum << endl; + + return 0; +} \ No newline at end of file diff --git a/range_checker.cpp b/range_checker.cpp new file mode 100644 index 0000000..ef3379f --- /dev/null +++ b/range_checker.cpp @@ -0,0 +1,37 @@ +#include +using namespace std; + +int main() { + int a; + int b; + int x; + + cout << "Введiть нижню межу дiапазону: "; + cin >> a; + + cout << "Введiть верхню межу дiапазону: "; + cin >> b; + + if (a > b) { + int temp = a; + a = b; + b = temp; + cout << "Границi помiняно мiсцями. Дiапазон: [" << a << ", " << b << "]" << endl; + } + + do { + cout << "Введiть число для перевiрки: "; + cin >> x; + + if (x < a || x > b) { + cout << "Число " << x << " не потрапляє в дiапазон [" + << a << ", " << b << "]" << endl; + } + + } while (x < a || x > b); + + cout << "Вiдмiнно! Число " << x << " потрапляє в дiапазон [" + << a << ", " << b << "]" << endl; + + return 0; +} diff --git a/remove_digits.cpp b/remove_digits.cpp new file mode 100644 index 0000000..4e9f3f2 --- /dev/null +++ b/remove_digits.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() { + int number; + int newNumber = 0; + int multiplier = 1; + + cout << "Введiть цiле число: "; + cin >> number; + + int originalNumber = number; + + while (number > 0) { + int digit = number % 10; + + if (digit != 3 && digit != 6) { + newNumber = newNumber + digit * multiplier; + multiplier *= 10; + } + + number = number / 10; + } + + cout << "Введене число: " << originalNumber << endl; + cout << "Нове число (без цифр 3 i 6): " << newNumber << endl; + + return 0; +} diff --git a/sum_calculator.cpp b/sum_calculator.cpp new file mode 100644 index 0000000..f6e211e --- /dev/null +++ b/sum_calculator.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main() { + int number; + int sum = 0; + + cout << "Введите числа (введите 0 для завершения):" << endl; + + cout << "Введите число: "; + cin >> number; + + while (number != 0) { + sum += number; + cout << "Текущая сумма: " << sum << endl; + + cout << "Введите число: "; + cin >> number; + } + + cout << "Итоговая сумма: " << sum << endl; + + return 0; +} diff --git a/task2.cpp b/task2.cpp index e735d65..3829c59 100644 --- a/task2.cpp +++ b/task2.cpp @@ -1,86 +1,82 @@ -#include -#include -#include -using namespace std; - -int main() { - setlocale(0, ""); - int l; - int q; - int c = 0; - - srand(time(0)); - - cout << "=== ПЕРЕВiРКА ТАБЛИЦi МНОЖЕННЯ ===" << endl; - cout << "Оберiть рiвень складностi:" << endl; - cout << "1) Легкий (1-5, 5 питань)" << endl; - cout << "2) Середнiй (1-10, 7 питань)" << endl; - cout << "3) Важкий (1-15, 10 питань)" << endl; - cout << "Введiть номер рiвня (1-3): "; - cin >> l; - - switch(l) { - case 1: - q = 5; - cout << "\n=== ЛЕГКИЙ РiВЕНЬ ===" << endl; - break; - case 2: - q = 7; - cout << "\n=== СЕРЕДНiЙ РiВЕНЬ ===" << endl; - break; - case 3: - q = 10; - cout << "\n=== ВАЖКИЙ РiВЕНЬ ===" << endl; - break; - default: - cout << "Невiрний вибiр!" << endl; - return 1; - } - - for (int i = 1; i <= q; i++) { - int a; - int b; - int ans; - int user; - - if (l == 1) { - a = rand() % 5 + 1; - b = rand() % 5 + 1; - } else if (l == 2) { - a = rand() % 10 + 1; - b = rand() % 10 + 1; - } else { - a = rand() % 15 + 1; - b = rand() % 15 + 1; - } - - ans = a * b; - - cout << "\nПитання " << i << "/" << q << ": " << a << " * " << b << " = "; - cin >> user; - - if (user == ans) { - cout << "Правильно! +1 бал" << endl; - c++; - } else { - cout << "Неправильно! Правильна вiдповiдь: " << ans << endl; - } - } - - cout << "\n=== РЕЗУЛЬТАТИ ===" << endl; - cout << "Правильних вiдповiдей: " << c << " з " << q << endl; - - double p = (double)c / q * 100; - - if (p >= 90) { - cout << "Оцiнка: ВiДМiННО! (5)" << endl; - } else if (p >= 80) { - cout << "Оцiнка: ДОБРЕ (4)" << endl; - } else if (p >= 70) { - cout << "Оцiнка: ЗАДОВiЛЬНО (3)" << endl; - } else { - cout << "Оцiнка: НЕЗАДОВiЛЬНО (2)" << endl; - } - - return 0; -} +#include +#include +#include +using namespace std; + +int main() { + int level; + int questions; + int correct = 0; + + srand(time(0)); + + cout << "=== ПЕРЕВIРКА ТАБЛИЦI МНОЖЕННЯ ===" << endl; + cout << "Оберiть рiвень складностi:" << endl; + cout << "1) Легкий (1-5, 5 питань)" << endl; + cout << "2) Середнiй (1-10, 7 питань)" << endl; + cout << "3) Важкий (1-15, 10 питань)" << endl; + cout << "Введiть номер рiвня (1-3): "; + cin >> level; + + switch(level) { + case 1: + questions = 5; + cout << "\n=== ЛЕГКИЙ РIВЕНЬ ===" << endl; + break; + case 2: + questions = 7; + cout << "\n=== СЕРЕДНIЙ РIВЕНЬ ===" << endl; + break; + case 3: + questions = 10; + cout << "\n=== ВАЖКИЙ РIВЕНЬ ===" << endl; + break; + default: + cout << "Невiрний вибiр!" << endl; + return 1; + } + + for (int i = 1; i <= questions; i++) { + int a, b, answer, userAnswer; + + if (level == 1) { + a = rand() % 5 + 1; + b = rand() % 5 + 1; + } else if (level == 2) { + a = rand() % 10 + 1; + b = rand() % 10 + 1; + } else { + a = rand() % 15 + 1; + b = rand() % 15 + 1; + } + + answer = a * b; + + cout << "\nПитання " << i << "/" << questions << ": " << a << " * " << b << " = "; + cin >> userAnswer; + + if (userAnswer == answer) { + cout << "Правильно! +1 бал" << endl; + correct++; + } else { + cout << "Неправильно! Правильна вiдповiдь: " << answer << endl; + } + } + + cout << "\n=== РЕЗУЛЬТАТИ ===" << endl; + cout << "Правильних вiдповiдей: " << correct << " з " << questions << endl; + + double percentage = (double)correct / questions * 100; + + if (percentage >= 90) { + cout << "Оцiнка: ВIДМIННО! (5)" << endl; + } else if (percentage >= 80) { + cout << "Оцiнка: ДОБРЕ (4)" << endl; + } else if (percentage >= 70) { + cout << "Оцiнка: ЗАДОВIЛЬНО (3)" << endl; + } else { + cout << "Оцiнка: НЕЗАДОВIЛЬНО (2)" << endl; + } + + return 0; +}