Загрузить файлы в «/»

This commit is contained in:
2025-09-18 19:34:13 +03:00
parent 17f6c3129b
commit 729e9a7503
5 changed files with 220 additions and 86 deletions

48
profit_analysis.cpp Normal file
View File

@@ -0,0 +1,48 @@
#include <iostream>
using namespace std;
int main() {
setlocale(0, "");
double profit[12];
const char* months[12] = {
"Сень", "Лютий", "Березень", "Кв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;
}

37
range_checker.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include <iostream>
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;
}

29
remove_digits.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include <iostream>
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;
}

24
sum_calculator.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include <iostream>
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;
}

168
task2.cpp
View File

@@ -1,86 +1,82 @@
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
using namespace std; using namespace std;
int main() { int main() {
setlocale(0, ""); int level;
int l; int questions;
int q; int correct = 0;
int c = 0;
srand(time(0));
srand(time(0));
cout << "=== ПЕРЕВIРКА ТАБЛИЦI МНОЖЕННЯ ===" << endl;
cout << "=== ПЕРЕВiРКА ТАБЛИЦi МНОЖЕННЯ ===" << endl; cout << "Оберiть рень складностi:" << endl;
cout << "Оберiть рень складностi:" << endl; cout << "1) Легкий (1-5, 5 питань)" << endl;
cout << "1) Легкий (1-5, 5 питань)" << endl; cout << "2) Середнiй (1-10, 7 питань)" << endl;
cout << "2) Середнiй (1-10, 7 питань)" << endl; cout << "3) Важкий (1-15, 10 питань)" << endl;
cout << "3) Важкий (1-15, 10 питань)" << endl; cout << "Введiть номер рiвня (1-3): ";
cout << "Введiть номер рiвня (1-3): "; cin >> level;
cin >> l;
switch(level) {
switch(l) { case 1:
case 1: questions = 5;
q = 5; cout << "\n=== ЛЕГКИЙ РIВЕНЬ ===" << endl;
cout << "\n=== ЛЕГКИЙ РiВЕНЬ ===" << endl; break;
break; case 2:
case 2: questions = 7;
q = 7; cout << "\n=== СЕРЕДНРIВЕНЬ ===" << endl;
cout << "\n=== СЕРЕДНРiВЕНЬ ===" << endl; break;
break; case 3:
case 3: questions = 10;
q = 10; cout << "\n=== ВАЖКИЙ РIВЕНЬ ===" << endl;
cout << "\n=== ВАЖКИЙ РiВЕНЬ ===" << endl; break;
break; default:
default: cout << "Невiрний вибiр!" << endl;
cout << "Невiрний вибiр!" << endl; return 1;
return 1; }
}
for (int i = 1; i <= questions; i++) {
for (int i = 1; i <= q; i++) { int a, b, answer, userAnswer;
int a;
int b; if (level == 1) {
int ans; a = rand() % 5 + 1;
int user; b = rand() % 5 + 1;
} else if (level == 2) {
if (l == 1) { a = rand() % 10 + 1;
a = rand() % 5 + 1; b = rand() % 10 + 1;
b = rand() % 5 + 1; } else {
} else if (l == 2) { a = rand() % 15 + 1;
a = rand() % 10 + 1; b = rand() % 15 + 1;
b = rand() % 10 + 1; }
} else {
a = rand() % 15 + 1; answer = a * b;
b = rand() % 15 + 1;
} cout << "\nПитання " << i << "/" << questions << ": " << a << " * " << b << " = ";
cin >> userAnswer;
ans = a * b;
if (userAnswer == answer) {
cout << "\nПитання " << i << "/" << q << ": " << a << " * " << b << " = "; cout << "Правильно! +1 бал" << endl;
cin >> user; correct++;
} else {
if (user == ans) { cout << "Неправильно! Правильна вiдповiдь: " << answer << endl;
cout << "Правильно! +1 бал" << endl; }
c++; }
} else {
cout << "Неправильно! Правильна вiдповiдь: " << ans << endl; cout << "\n=== РЕЗУЛЬТАТИ ===" << endl;
} cout << "Правильних вiдповiдей: " << correct << " з " << questions << endl;
}
double percentage = (double)correct / questions * 100;
cout << "\n=== РЕЗУЛЬТАТИ ===" << endl;
cout << "Правильних вiдповiдей: " << c << " з " << q << endl; if (percentage >= 90) {
cout << "Оцiнка: ВМIННО! (5)" << endl;
double p = (double)c / q * 100; } else if (percentage >= 80) {
cout << "Оцiнка: ДОБРЕ (4)" << endl;
if (p >= 90) { } else if (percentage >= 70) {
cout << "Оцiнка: ВМiННО! (5)" << endl; cout << "Оцiнка: ЗАДОВЬНО (3)" << endl;
} else if (p >= 80) { } else {
cout << "Оцiнка: ДОБРЕ (4)" << endl; cout << "Оцiнка: НЕЗАДОВЬНО (2)" << endl;
} else if (p >= 70) { }
cout << "Оцiнка: ЗАДОВЬНО (3)" << endl;
} else { return 0;
cout << "Оцiнка: НЕЗАДОВЬНО (2)" << endl; }
}
return 0;
}