Petro_zzz

lesson7_322

Jul 18th, 2023
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. void divided3() {
  7.     int k = 0;
  8.     cout << "Введите число :";
  9.     cin >> k;
  10.    
  11.     if (k % 3 == 0) {
  12.         cout << "Делится";
  13.     }
  14.     else {
  15.         cout << "Не делится";
  16.     }
  17.     cout << endl;
  18. }
  19.  
  20. void from_min_to_max() {
  21.     double a, b;
  22.     cout << "Введите два числа: \n";
  23.     cin >> a >> b;
  24.  
  25.     if (a < b) {
  26.         cout << a << ", " << b;
  27.     }
  28.     else {
  29.         cout << b << ", " << a;
  30.     }
  31.     cout << endl;  
  32. }
  33.  
  34. void from_min_to_max2() {  
  35.     double a, b;
  36.     cout << "Введите два числа: \n";
  37.     cin >> a >> b;
  38.  
  39.     if (a < b) {
  40.         cout << a << ", " << b;
  41.     }
  42.     else {
  43.         if (a > b) {
  44.             cout << b << ", " << a;
  45.         }
  46.         else {
  47.             cout << "Равны " << a;
  48.         }
  49.     }
  50.     cout << endl;
  51. }
  52.  
  53. void baby() {
  54.     cout << 1 << ", ";
  55.     cout << 2 << ", ";
  56.     goto vasya;
  57.     cout << 3 << ", ";
  58.     vasya: cout << 4 << ", ";
  59.     cout << 5 << endl;
  60. }
  61.  
  62. void test_repeat() {
  63. repeat: from_min_to_max();
  64.     char ch;
  65.     cout << "Повторим? (y если да)";
  66.     cin >> ch;
  67.     if ((ch == 'y') || (ch == 'Y'))
  68.         goto repeat;
  69. }
  70.  
  71. void test_getch() {
  72.     char a;
  73.     //cin >> a;
  74.     a = _getch(); // В отлиичии от cin не дожидается нажатия Enter
  75.     // и не выводит ничего на консоль
  76.     cout << (char)(a + 1);
  77.     cout << (char)(a + 1);
  78.     cout << (char)(a + 1);
  79. }
  80.  
  81.  
  82. void admittance() {
  83.     int ball, summ = 0;
  84.  
  85.     cin >> ball;
  86.     summ = summ + ball;
  87.     cin >> ball;
  88.     summ = summ + ball;
  89.     cin >> ball;
  90.     summ = summ + ball;
  91.     cin >> ball;
  92.     summ = summ + ball;
  93.     cin >> ball;
  94.     summ = summ + ball;
  95.  
  96.     if (summ >= 5 * 4)
  97.         cout << "Допущен";
  98.     else
  99.         cout << "Не допущен";
  100.     cout << endl;
  101. }
  102.  
  103.  
  104. void admittance2() {
  105.     int a1, a2, a3, a4, a5, summ = 0;
  106.     cin >> a1 >> a2 >> a3 >> a4 >> a5;
  107.     summ = a1 + a2 + a3 + a4 + a5;
  108.     double aver = summ / 5.0;
  109.     if (aver >= 4)
  110.         cout << "Допущен";
  111.     else
  112.         cout << "Не допущен";
  113.     cout << endl;
  114. }
  115.  
  116. void do_calc() {
  117.     double x, y;
  118.     char op;
  119.     cout << "Введите выражение: "
  120.          << "(число) (оператор +, -, *, / ) (число)" << endl;
  121.     cin >> x >> op >> y;
  122.     cout << x << op << y << " = ";
  123.     if (op == '+')
  124.         cout << x + y;
  125.     else if (op == '-')
  126.         cout << x - y;
  127.     else if (op == '*')
  128.         cout << x * y;
  129.     else if (op == '/')
  130.         if (abs(y) > 1.e-6) // ((y < -1.e-6) || (y > 1.e-6))
  131.             cout << x / y;
  132.         else
  133.             cout << "Очень маленький y";
  134.  
  135.     cout << endl;
  136. }
  137.  
  138. void test_eqal_double() {
  139.     float x, y;
  140.    
  141.     x = 0.1;
  142.     y = 0.5;
  143.  
  144.     if ((x+x+x+x+x) == y) {
  145.         cout << "Ok" << endl;
  146.     }
  147.     else {
  148.         cout << "Странно" << endl;
  149.     }
  150.  
  151.     double eps = (x + x + x + x + x) - y;
  152.     cout << eps;
  153.  
  154. }
  155.  
  156. void is_round(double r1, double r2){
  157.     cout << "Введите координаты";
  158.     double x, y, r;
  159.     cin >> x >> y;
  160.     r = sqrt(pow(x,2) + pow(y,2));
  161.     if ((r > r1) && (r < r2)) {
  162.         cout << "Ok" << endl;
  163.     }
  164.     else {
  165.         cout << "Не Ок" << endl;
  166.     }
  167. }
  168.  
  169. int main() {
  170.     setlocale(LC_ALL, "ru");
  171.     //divided3();
  172.     //test_repeat();
  173.     //from_min_to_max2();
  174.     //baby();
  175.     //admittance();
  176.     //do_calc();
  177.     //test_eqal_double();
  178.     is_round(5, 10);
  179.     system("pause");
  180.     return 0;
  181. }
Advertisement
Add Comment
Please, Sign In to add comment