Files
IT-Step/analysis.cpp
2025-09-11 19:40:48 +03:00

42 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}
}
cout << "\nРезультати аналiзу:" << endl;
cout << "Мiсяць з максимальним прибутком: " << months[maxIndex]
<< " (прибуток: " << profit[maxIndex] << ")" << endl;
cout << "Мiсяць з мiнiмальним прибутком: " << months[minIndex]
<< " (прибуток: " << profit[minIndex] << ")" << endl;
return 0;
}