Petro_zzz

311_2901

Jan 29th, 2024
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void my_abs() {
  6.     double x;
  7.     cout << "Enter x: "; cin >> x;
  8.     if (x < 0) {
  9.         x = -x;
  10.     }
  11.     /*
  12.     else {
  13.         //x = x;
  14.     }
  15.     */
  16.     cout << "|x|: " << x << endl;
  17. }
  18.  
  19. void my_abs_short() {
  20.     double x, result;
  21.     cout << "Enter x: "; cin >> x;
  22.    
  23.     if (x < 0)
  24.         result = -x;
  25.     else
  26.         result = x;
  27.  
  28.     cout << "| " << x << " |= " << result << endl;
  29. }
  30.  
  31. double abs_short(double x) {
  32.     if (x < 0) x = -x;
  33.     return x;
  34. }
  35.  
  36. void get_max() {
  37.  
  38.     double x1 = 5;
  39.     double x2 = 3;
  40.     double x3 = 7;
  41.  
  42.     double max = x1;
  43.  
  44.     if (x2 > max) {
  45.         max = x2;
  46.     }
  47.  
  48.     if (x3 > max) {
  49.         max = x3;
  50.     }
  51.  
  52.     cout << max << endl;
  53. }
  54.  
  55. void is_button_click() {
  56.     const int win_width = 1920;
  57.     const int win_heigh = 1080;
  58.  
  59.     const int button_width = 100;
  60.     const int button_height = 50;
  61.     const int button_x = 700;
  62.     const int button_y = 600;
  63.  
  64.     int x = 700;
  65.     int y = 611;
  66.  
  67.     bool is_click = true;
  68.  
  69.     // Проверка попадания в экран
  70.     if (x < 0) {
  71.         is_click = false;  
  72.     }
  73.     if (y < 0) {
  74.         is_click = false;
  75.     }
  76.     if (x > win_width) {
  77.         is_click = false;  
  78.     }
  79.     if (y > win_heigh) {
  80.         is_click = false;
  81.     }
  82.  
  83.     // Проверка клика по кнопке
  84.     if (x < button_x) {
  85.         is_click = false;
  86.     }
  87.     if (y < button_y) {
  88.         is_click = false;
  89.     }
  90.     if (x > button_width + button_x) {
  91.         is_click = false;
  92.     }
  93.     if (y > button_height + button_y) {
  94.         is_click = false;
  95.     }
  96.  
  97.     if (is_click) {
  98.         cout << "Bingo" << endl;
  99.     }
  100.     else {
  101.         cout << "Milk" << endl;
  102.     }
  103. }
  104.  
  105. int main() {
  106.     //my_abs_short();
  107.     //cout << abs_short(-7) << endl;
  108.     //get_max();
  109.     is_button_click();
  110.  
  111.     system("pause");
  112.     return 0;
  113. }
Add Comment
Please, Sign In to add comment