westron

clone

Apr 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #define _USE_MATH_DEFINES
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <conio.h>
  7. #include <locale.h>
  8. #include <Windows.h>
  9. #include <string.h>
  10. #include <math.h>
  11.  
  12. struct PAIR
  13. {
  14.     double X;
  15.     double Y;
  16.     void operator()(double d1, double d2)
  17.     {
  18.         X = d1;
  19.         Y = d2;
  20.     }
  21. };
  22.  
  23. int main()
  24. {
  25.     setlocale(LC_ALL, "");
  26.  
  27.     SetConsoleCP(1251); SetConsoleOutputCP(1251);
  28.    
  29.     double W, Q, P, a(12.4), b(3.62), x;
  30.  
  31.  
  32.     PAIR M1, M2;
  33.     M1(8.21, -8.1);
  34.     M2(2.14, 15.81);
  35.  
  36.     printf("x = ");
  37.     scanf("%f", &x);
  38.     getchar();
  39.  
  40.     Q = 6.28 + sin(x) - (a*b) / (a + b);
  41.  
  42.     if (sqrt(pow(fabs(M2.X-M1.X),2)+pow(fabs(M2.Y-M1.Y),2))==0)
  43.     {
  44.         W = Q;
  45.         printf("W = Q = %f", W);
  46.         _getch();
  47.     }
  48.     else
  49.     {
  50.         P = Q / 31.0;
  51.         printf("P = %f", P);
  52.         _getch();
  53.     }
  54.     return 0;
  55. }
Add Comment
Please, Sign In to add comment