Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- float kpop(float x) {
- float y;
- y = (x*x - 2 * x + 2) / (x - 1);
- return(y);
- }
- void hw2_1();
- void hw2_2();
- void hw2_3();
- void hw2_4();
- void hw2_5();
- int main()
- {
- setlocale(LC_ALL, "russian");
- hw2_1();
- hw2_2();
- hw2_3();
- hw2_4();
- hw2_5();
- return 0;
- }
- void hw2_1() {
- float R, r, V, S, h, l;
- const float pi = 3.14;
- cout << "Введите R, r, h, l: ";
- cin >> R >> r >> h >> l;
- if (R > 0 && r > 0 && h > 0 && l > 0) {
- if ((l == sqrt(pow(R - r, 2.0) + pow(h, 2.0)))&&(R>r)) {
- S = pi * (R*R + (R + r)*l + r * r);
- V = (1.f / 3.f)*pi*h*(R*R + R * r + r * r);
- cout << "V=" << V << endl;
- cout << "S=" << S << endl;
- }
- else cout << "Такого конуса не существует!" <<endl;
- }
- else cout << "R, r, h и l должны быть положительными!";
- }
- void hw2_2() {
- float a, w, x;
- cout << "Введите x и a: ";
- cin >> x >> a;
- if (abs(x) < 1) {
- w = a * log(abs(x));
- cout << "w=" << w;
- }
- else {
- if (a >= (x * x)) {
- w = sqrt(a - x * x);
- cout << "w=" << w;
- }
- else cout << "a должен быть больше квадрата x!" << endl;
- }
- }
- void hw2_3() {
- float x, y, b;
- cout << "Введите x, y, b: ";
- cin >> x >> y >> b;
- if (b > y && b > x)
- cout << "z=" << log(b - y)*sqrt(b - x) << endl;
- else cout << "b должен быть больше y и x" << endl;
- }
- void hw2_4() {
- int N, i = 0;
- cout << "Введите N: ";
- cin >> N;
- while (i != 10) {
- cout << N++ << " ";
- i++;
- }
- cout << endl;
- }
- void hw2_5() {
- for (float x = -4; x <= 4; x = x + 0.5) {
- if (x != 1) {
- cout << "x=" << x << " y=" << kpop(x) << endl;
- }
- else cout << "x=" << x << " нет корней" << endl;
- }
- }
Add Comment
Please, Sign In to add comment