Untitled

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cmath> using namespace std; void task59() { cout << "Current date is 11.2019" << endl; int currentyear = 2019, currentmonth = 11, bornyear, bornmonth, age; cout << "Enter year of birth :"; cin >> bornyear; if (0 <= bornyear && bornyear <= 2019) { cout << "\nEnter month of birth :"; cin >> bornmonth; if (0 <= bornmonth && bornmonth<= 12){ if (currentmonth - bornmonth < 0) age = currentyear - bornyear - 1; else age = currentyear - bornyear; cout << "Age is " << age << endl << endl; } else cout << "Incorrect month" << endl; } else cout << "Incorrect year" << endl; } void task70() { int a, b, c, d; cout << "Enter size of table :"; cin >> a; cin >> b; cout << "Your size : "<<a<<"x"<<b; cout << "\nEnter size of rectangle :"; cin >> c; cin >> d; cout << "Your size : " << c << "x" << d; if (a > b && c > d) { if (((a / c) * (b / d)) > ((b / c) * (a / d))) cout << "\nAlong the long side"; else if (((a / c) * (b / d)) < ((b / c) * (a / d))) cout << "\nAlong the short side"; else cout << "\nEqual"; cout << endl << endl; } else cout << "\nМalues do not meet the condition" << endl<<endl; } void task81() { int angleA, angleB; cout << "Enter angleA, than angleB: "; cin >> angleA >> angleB; if (angleA + angleB < 180) { cout << "\nTriangle exists"; if (angleA == 90 || angleB == 90 || angleA + angleB == 90) cout << "\nTriangle is right"; else cout << "\nTriangle isn't right"; } else cout << "\nTriangle doesn't exist"; cout << endl << endl; } void task92() { double x, y, z; cout << "Enter x, then y" << endl; cin >> x >> y; if (x > y) { cout << "x is " << x << " " << "y is " << y; } else { if (x < y) { z = x, x = y, y = z, cout << "x is " << x << " " << "y is " << y; } else if (x == y) { cout << "x and y are equal"; } } cout << endl << endl; } void task103() { int a, b, c; cout << "Enter a, than b, than c :"<<endl; cin >> a >> b >> c; if (a * a + b * b == c * c) cout << "Triangle is right, hypotenuse is c"; else if (b * b + c * c == a * a) cout << "Triangle is right, hypotenuse is a"; else if (c * c + a * a == b * b) cout << "Triangle is right, hypotenuse is b"; else cout << "a, b and c doesn't compose a right triangle"; cout << endl << endl; } void task114() { double a, b, c; cout << "Enter a, than b, than c :" << endl; cin >> a >> b >> c; if (a <= b && b <= c) a = a * 2, b = b * 2, c = c * 2; else a = abs(a), b = abs(b), c = abs(c); cout << a << " " << b << " " << c << endl << endl; } void task125() { double number1, number2, number3; cout << "Enter number1, number2, number3\n"; cin >> number1 >> number2 >> number3; if (number1 + number1 > 0 || number1 + number3 > 0 || number2 + number3 > 0) cout << "Sum of two of them is positive"; else cout << "There isn't a positive sum"; cout << endl << endl; } void task136() { int number1, number2; cout << "Enter number1, than number2 :"<<endl; cin >> number1 >> number2; if (number1 % number2 == 0 || number2 % number1 == 0) cout << "One of them is divider to another"; else cout << "None of them is divider to other"; cout << endl << endl; } void task147() { cout << "Enter natural 'n' <= 9999\n"; int n; cin >> n; if (n > 0 && n <= 9999) { cout << "\nn = " << n << endl; int thousand = n / 1000, hundred = n % 1000 / 100, dozen = n % 100 / 10, one = n % 10; if (thousand == hundred && thousand == dozen && dozen == hundred) cout << "Three numerals of the number are equal"; else if (hundred == dozen && dozen == one && hundred == one) cout << "Three numerals of the number are equal"; else if (thousand == dozen && thousand == one && dozen == one) cout << "Three numerals of the number are equal"; else if (thousand == hundred && thousand == one && hundred == one) cout << "Three numerals of the number are equal"; else cout << "Three numerals of the number aren't equal"; } else cout << "n doesn't fit the condition"; cout << endl << endl; } void task158() { double X, Y, Z; cout << "Enter three real numbers: X, Y, Z\n"; cin >> X >> Y >> Z; cout << "X = " << X << " Y = " << Y << " Z = " << Z << endl; if (X + Y + Z < 1) { cout << "Sum is less than 1\n"; ((X < Y && X < Z) ? X = (Y + Z) / 2 : ((Y < X && Y < Z) ? Y = (X + Z) / 2 : Z = (X + Y) / 2)); } else { cout << "Sum is more or equal 1\n", (X < Y ? X = (Y + Z) / 2 : Y = (X + Z) / 2); } cout << "X = " << X << " Y = " << Y << " Z = " << Z << endl << endl; } int main() { int a; while (true) { cout << "Numbers of tasks are 59 70 81 92 103 114 125 136 147 158\n"; cin >> a; cout << endl; switch (a) { case 59: task59(); break; case 70: task70(); break; case 81: task81(); break; case 92: task92(); break; case 103: task103(); break; case 114: task114(); break; case 125: task125(); break; case 136: task136(); break; case 147: task147(); break; case 158: task158(); break; case 0: return(0); break; default: cout << "Incorrect number, try again" << endl; break; } } }
Editor Settings
Theme
Key bindings
Full width
Lines