Advertisement
Balda

Untitled

Jan 16th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. void func1(double a, double b, double c);
  7. void func2(double a, double b, double c, double d);
  8. void func3(char c, double x);
  9. void func4(double x1, double y1, double x2, double y2);
  10.  
  11. void func1(double a, double b, double c){
  12.     if (b >= c && b <= a){
  13.         a *= 2;
  14.         b *= 2;
  15.         c *= 2;
  16.     }
  17.     else{
  18.         a = fabs(a);
  19.         b = fabs(b);
  20.         c = fabs(c);
  21.     }
  22.  
  23. }
  24.  
  25. void func2(double a, double b, double c, double d){
  26.     double t;
  27.     if (a>b){
  28.         t = a;
  29.         a = b;
  30.         b = t;
  31.     }
  32.     if (c>d){
  33.         t = c;
  34.         c = d;
  35.         d = t;
  36.     }
  37.     if (a<c && b<d)
  38.         cout << "YES" << endl;
  39.     else
  40.         cout << "NO" << endl;
  41.  
  42. }
  43.  
  44. void func3(char c, double x){
  45.     switch (c){
  46.     case 'k':
  47.         cout << "S=" << x*x / 2 << endl << "g=" << sqrt(x*x + x*x) << endl;
  48.         break;
  49.     case 'g':
  50.         cout << "S=" << x*x / 4 << endl << "k=" << sqrt(x*x / 2) << endl;
  51.         break;
  52.     case 's':
  53.         cout << "k=" << sqrt(2 * x) << endl << "g=" << sqrt(2 * x*x) << endl;
  54.         break;
  55.     default:
  56.         break;
  57.     }
  58. }
  59.  
  60. void func4(double x1, double y1, double x2, double y2){
  61.     if (sqrt(x1*x1 + y1*y1)<sqrt(x2*x2 + y2*y2))
  62.         cout << 'A' << endl;
  63.     else
  64.         cout << 'B' << endl;
  65. }
  66.  
  67. int main(){
  68.     double a, b, c, d;
  69.     char s;
  70.  
  71.     cout << "1)Vvedite a, b, c:" << endl;
  72.     cin >> a >> b >> c;
  73.     func1(a, b, c);
  74.     cout << a << ' ' << b << ' ' << c << endl;
  75.  
  76.     cout << "2)Vvedite a, b, c, d:" << endl;
  77.     cin >> a >> b >> c >> d;
  78.     func2(a, b, c, d);
  79.  
  80.     cout << "3)Vyberete: k - katet, g - gipotenuza s - ploschad'" << endl << "Vvedite velichinu x:" << endl;
  81.     cin >> s >> a;
  82.     func3(s, a);
  83.  
  84.     cout << "4)Vvedite x1, y1, x2, y2:" << endl;
  85.     cin >> a >> b >> c >> d;
  86.     func4(a, b, c, d);
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement