Untitled
unknown
c_cpp
a year ago
3.5 kB
1
Indexable
Never
#include <iostream> #include <string.h> int main() { setlocale(LC_ALL, "Russian"); int bestAvg = 0; int worstAvg = 5; std::string worst = ""; std::string best = ""; int total = 0; float avg = 0; int count = 0; int totalE = 0; float avgE = 0; int countE = 0; int totalR = 0; float avgR = 0; int countR = 0; int totalM = 0; float avgM = 0; int countM = 0; int input = 0; char subject = ' '; std::cout << "Добавить оценку: 1 \n" << "Посмотреть средний бал: 1 \n" << "Посмотреть предметы с худшей и лучшей успеваемостью: 3 \n" << "Выйти: 4 \n"; while (true) { std::cin >> input; switch (input) { case 1: std::cin >> input >> subject; switch (subject) { std::cout << "Математика: M \n" "Русский: R \n" "Английский: E \n"; case 'E': totalE += input; countE++; avgE = (float)totalE / countE; switch (avgE > bestAvg) { case true: bestAvg = avgE; best = "Английский"; break; } switch (avgE < worstAvg) { case true: worstAvg = avgE; worst = "Английский"; break; } break; case 'R': totalR += input; countR++; avgR = (float)totalR / countR; switch (avgE > bestAvg) { case true: bestAvg = avgE; best = "Русский"; break; } switch (avgE < worstAvg) { case true: worstAvg = avgE; worst = "Русский"; break; } break; case 'M': totalM += input; countM++; avgM = (float)totalM / countM; switch (avgE > bestAvg) { case true: bestAvg = avgE; best = "Математика"; break; } switch (avgE < worstAvg) { case true: worstAvg = avgE; worst = "Математика"; break; } break; } total += input; count++; avg = (float)total / count; break; case 2: std::cout << "По всем предметам: " << avg << "\nПо математике: " << avgM << "\nПо русскому языку: " << avgR << "\nПо английскому языку: " << avgE << std::endl; break; case 3: std::cout << "C худшей успеваемостью: " << worst << "\nC лучшей успеваемостью: " << best; break; case 4: return 0; } } }