/
lyapdy
/
Object_oriented_programming_cpp_318
Обзор
Документация
Войти
/
lyapdy
/
Object_oriented_programming_cpp_318
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lab3/main.cpp
175 строк
6 KB
lyapdy
min_max_5
20 май 2025, 16:57
20 май 2025, 16:57
f6b02a1
Код
Авторство
О чём код?
/* * ������ୠ� ࠡ�� No1 *��������� �㭪権 �++ � IDE (��⥣������ �।� ࠧ�- ��⪨) Qt Creator * Developer: Danil Lyapunov * OS: Windows 11 * locale (������ ): IBM866 / CP866 / csIBM866 */ #include<iostream> #include"unit_1.h" #include"unit_2.h" #include"unit_3.h" #include"unit_4.h" #include"unit_5.h" #include"unit_6.h" #include"unit_7.h" #define Unit 5 static int gValue{1}; int main() { #if Unit == 1 std::cout << "������� 1" << std::endl; std::cout << '\n'; int aces_number = 4; int cards_number = 52; std::cout << "�) ����⭮��� ⮣�, �� ��砩�� ���饭��� ���� �� ������," << '\n'; std::cout << "����饩 �� 52 ����, �������� �㧮�, ࠢ��: " << probability(aces_number, cards_number) << '\n'; std::cout << '\n'; std::cout << "�) ����⭮��� ⮣�, �� �㬬� �窮�, �믠��� �� ����," << '\n'; int lucky_seven_combination = 6; // 1,6; 6,1; 2,5; 5,2; 3,4; 4,3 int possible_combinations_number = 6 * 6; std::cout << "��ࠫ��� ������ � ����� �����, ࠢ�� 7, ��⠢���: " << probability(lucky_seven_combination, possible_combinations_number) << '\n'; std::cout << '\n'; std::cout << "�) ����⭮��� ⮣�, �� �� ��砩��� �ᯮ�������" << '\n'; int rearrangements_number = 4 * 3 * 2 * 1; int mama_combinations_number = 4; std::cout << "�㪢 � �� ॡ���� ������ �� \"����\", ࠢ��: " << probability(mama_combinations_number, rearrangements_number) << '\n'; std::cout << '\n'; #elif Unit == 2 std::cout << "������� 2" << std::endl; // �맮� �㭪樨 ������� 2 �� �⤥�쭮�� 䠩�� (*.h ) ��� ����� (*.��� + *.h) printChar('a', 'b', 'c', 'd'); printChar('a', 'b', 'c'); printChar('a', 'b'); printChar('a'); printChar(); #elif Unit == 3 std::cout << "������� 3" << std::endl; // �맮� �㭪樨 ������� 3 �� �⤥�쭮�� 䠩�� (*.h ) ��� ����� (*.��� + *.h) int gValue{5}; // �����쭠� ��६����� std::cout << "���祭�� �����쭮� ��६����� gValue = " << gValue << '\n'; // gValue = 5 std::cout << "���祭�� ������쭮� ��६����� gValue = " << ::gValue << '\n'; // gValue = 1 initVal(); // } #elif Unit == 4 std::cout << "������� 4" << std::endl; // �맮� �㭪樨 ������� 3 �� �⤥�쭮�� 䠩�� (*.h ) ��� ����� (*.��� + *.h) std::cout << '\n'; int number = 5; std::cout << "������ ����� ����⭮�� 0 - ���ᥭ��, 1 - ����, 2 - �����, 3 - ���, 4 - ᮡ���: " << '\n'; while (!(std::cin >> number) || (std::cin.peek() != '\n')) { std::cin.clear(); while ((std::cin.get() != '\n')); std::cout << "Error!" << std::endl;} switch(number) { case 0: getAnimalName(pig); printNumberOfLegs(pig); break; case 1: getAnimalName(chicken); printNumberOfLegs(chicken); break; case 2: getAnimalName(goat); printNumberOfLegs(goat); break; case 3: getAnimalName(cat) ; printNumberOfLegs(cat); break; case 4: getAnimalName(dog); printNumberOfLegs(dog); break; default: std::cout << "Unknown\n"; // � ��祣� �� ᮢ���� break; } #elif Unit == 5 std::cout << "������� 5" << std::endl; // �맮� �㭪樨 ������� 3 �� �⤥�쭮�� 䠩�� (*.h ) ��� ����� (*.��� + *.h) std::cout << "������ ��ࢮ� �: " << '\n'; int num1 = 0; while (!(std::cin >> num1) || (std::cin.peek() != '\n')) { std::cin.clear(); while ((std::cin.get() != '\n')); std::cout << "Error!" << std::endl;} std::cout << "������ �� �: " << '\n'; int num2 = 0; while (!(std::cin >> num2) || (std::cin.peek() != '\n')) { std::cin.clear(); while ((std::cin.get() != '\n')); std::cout << "Error!" << std::endl;} std::cout << "������� �� �।���? 0 - ���, 1 - ��: " << '\n'; int option; while (!(std::cin >> option) || (std::cin.peek() != '\n')) { std::cin.clear(); while ((std::cin.get() != '\n')); std::cout << "Error!" << std::endl;} int limit_min = 0; int limit_max = 0; switch (option) { case 0: limit_min =10; limit_max = 100; break; case 1: std::cout << "������ ������ �।��: " << '\n'; while (!(std::cin >> limit_min) || (std::cin.peek() != '\n')) { std::cin.clear(); while ((std::cin.get() != '\n')); std::cout << "Error!" << std::endl;} std::cout << "������ ���孨� �।��: " << '\n'; while (!(std::cin >> limit_max) || (std::cin.peek() != '\n')) { std::cin.clear(); while ((std::cin.get() != '\n')); std::cout << "Error!" << std::endl;} break; } std::cout << "func_max(" << num1 << ", " << num2 <<") = " << func_max(num1, num2) << '\n'; std::cout << "func_max(" << num1 << ", " << num2 <<") = " << func_max(num1, num2) << '\n'; std::cout << "func_max(" << num1 << ", " << num2 << ", " << limit_min << ", " <<limit_max <<") = " << func_max(num1, num2, limit_min, limit_max) << '\n'; std::cout << "func_min(" << num1 << ", " << num2 <<") = " << func_min(num1, num2) << '\n'; std::cout << "func_min(" << num1 << ", " << num2 <<") = " << func_min(num1, num2) << '\n'; std::cout << "func_min(" << num1 << ", " << num2 << ", " << limit_min << ", " <<limit_max <<") = " << func_min(num1, num2, limit_min, limit_max) << '\n'; #elif Unit == 6 std::cout << "������� 6" << std::endl; // �맮� �㭪樨 ������� 3 �� �⤥�쭮�� 䠩�� (*.h ) ��� ����� (*.��� + *.h) print_conversion_result(); #else std::cout << "������� 7" << std::endl; // �맮� �㭪樨 ������� 4 �� �⤥�쭮�� 䠩�� (*.h ) ��� ����� (*.��� + *.h) elevatoring(); #endif return 0; }