Kolyach

2

Sep 10th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. float kpop(float x) {
  8.     float y;
  9.     y = (x*x - 2 * x + 2) / (x - 1);
  10.     return(y);
  11. }
  12.  
  13. void hw2_1();
  14. void hw2_2();
  15. void hw2_3();
  16. void hw2_4();
  17. void hw2_5();
  18.  
  19. int main()
  20. {
  21.     setlocale(LC_ALL, "russian");
  22.     hw2_1();
  23.     hw2_2();
  24.     hw2_3();
  25.     hw2_4();
  26.     hw2_5();
  27.     return 0;
  28. }
  29.  
  30. void hw2_1() {
  31.     float R, r, V, S, h, l;
  32.     const float pi = 3.14;
  33.     cout << "Введите R, r, h, l: ";
  34.     cin >> R >> r >> h >> l;
  35.     if (R > 0 && r > 0 && h > 0 && l > 0) {
  36.         if ((l == sqrt(pow(R - r, 2.0) + pow(h, 2.0)))&&(R>r)) {
  37.             S = pi * (R*R + (R + r)*l + r * r);
  38.             V = (1.f / 3.f)*pi*h*(R*R + R * r + r * r);
  39.             cout << "V=" << V << endl;
  40.             cout << "S=" << S << endl;
  41.         }
  42.         else cout << "Такого конуса не существует!" <<endl;
  43.     }
  44.     else cout << "R, r, h и l должны быть положительными!";
  45. }
  46.  
  47. void hw2_2() {
  48.     float a, w, x;
  49.     cout << "Введите x и a: ";
  50.     cin >> x >> a;
  51.     if (abs(x) < 1) {
  52.         w = a * log(abs(x));
  53.         cout << "w=" << w;
  54.     }
  55.     else {
  56.         if (a >= (x * x)) {
  57.             w = sqrt(a - x * x);
  58.             cout << "w=" << w;
  59.         }
  60.         else cout << "a должен быть больше квадрата x!" << endl;
  61.     }
  62. }
  63.  
  64. void hw2_3() {
  65.     float x, y, b;
  66.     cout << "Введите x, y, b: ";
  67.     cin >> x >> y >> b;
  68.     if (b > y && b > x)
  69.         cout << "z=" << log(b - y)*sqrt(b - x) << endl;
  70.     else cout << "b должен быть больше y и x" << endl;
  71. }
  72.  
  73. void hw2_4() {
  74.     int N, i = 0;
  75.     cout << "Введите N: ";
  76.     cin >> N;
  77.     while (i != 10) {
  78.         cout << N++ << " ";
  79.         i++;
  80.     }
  81.     cout << endl;
  82. }
  83.  
  84. void hw2_5() {
  85.     for (float x = -4; x <= 4; x = x + 0.5) {
  86.         if (x != 1) {
  87.             cout << "x=" << x << "     y=" << kpop(x) << endl;
  88.         }
  89.         else cout << "x=" << x << "     нет корней" << endl;
  90.     }
  91. }
Add Comment
Please, Sign In to add comment