Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define _USE_MATH_DEFINES
- #include <math.h>
- using namespace std;
- void checkVar() {
- int var;
- cout << "Input ";
- cin >> var;
- if (var > 0)
- cout << "positive" << endl;
- else {
- if (var < 0)
- cout << "negative" << endl;
- else
- cout << "zero" << endl;
- }
- }
- void calcVolume() {
- int isSphere = 0;
- cout << "Что вы хотите вычислить?" << endl;
- cout << "1 - Объём шара" << endl;
- cout << "2 - Объём куба" << endl;
- cin >> isSphere;
- //const double pi = M_PI;
- double volume = 0;
- double size = 0;
- if (isSphere == 1) {
- cout << "Введите радиус" << endl;
- cin >> size;
- volume = 3.0 / 4.0 * M_PI * size * size * size;
- }
- else if (isSphere == 2) {
- cout << "Введите сторону" << endl;
- cin >> size;
- volume = size * size * size;
- } else {
- cout << "Ошибка" << endl;
- }
- cout << "Объём " << volume << endl;
- }
- void calcPrice() {
- /*Покупатель покупает N дисков по M рублей.
- Если сумма покупки больше 10000 рублей, то
- скидка составит 10 %, если число дисков больше 4,
- то 5 диск достаётся в подарок.*/
- int num, price;
- const double sale = 0.1;
- const int minPriceForSale = 10000;
- const int numForGift = 4;
- cout << "Введите число дисков ";
- cin >> num;
- cout << "Введите цену каждого диска ";
- cin >> price;
- if (num > numForGift) {
- num = num - 1;
- cout << "Один диск в подарок." << endl;
- }
- if (num * price > minPriceForSale) {
- cout << "Ваша скидка 10%" << endl;
- cout << "К оплате " << num * price * (1 - sale) << " рублей.";
- }
- else {
- cout << "К оплате " << num * price << " рублей.";
- }
- }
- void isInSquare() {
- int x, y; // point
- int x0, y0, a; // square
- cout << "Input point ";
- cin >> x >> y;
- cout << "Input x0, y0, a for square ";
- cin >> x0 >> y0 >> a;
- int xmin = x0;
- int xmax = x0 + a;
- int ymin = y0;
- int ymax = y0 + a;
- bool ex = (x >= xmin) && (x <= xmax) &&
- (y >= ymin) && (y <= ymax);
- if (ex)
- cout << "The point in square";
- else
- cout << "The point no in square";
- }
- void ring() {
- int x, y; // point
- int x0, y0, R1, R2; // ring
- cout << "Input point ";
- cin >> x >> y;
- cout << "Input x0, y0, r1, r2 for ring ";
- cin >> x0 >> y0 >> R1 >> R2;
- int RR = pow((x - x0), 2) + pow((y - y0), 2);
- if (R1 * R1 < RR < R2 * R2)
- cout << "The point in ring";
- else
- cout << "The point no in ring";
- }
- int main(){
- setlocale(LC_ALL, "Russian");
- // просто раскомментируй то, что нужно
- //checkVar();
- //calcVolume();
- //calcPrice();
- //isInSquare();
- //ring();
- }
Advertisement
Add Comment
Please, Sign In to add comment