Skip to content

Instantly share code, notes, and snippets.

@ukoloff
Created September 19, 2018 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukoloff/2ba54476f0c289dcb671f456a9fe0edc to your computer and use it in GitHub Desktop.
Save ukoloff/2ba54476f0c289dcb671f456a9fe0edc to your computer and use it in GitHub Desktop.
algo-1 created by ukoloff - https://repl.it/@ukoloff/algo-1
#include <iostream>
#include <cmath>
int main() {
std::cout << "Введите два числа:";
int a, b;
std::cin >> a >> b;
std::cout << a << " + " << b << " = " << a + b << std::endl;
std::cout << a << " - " << b << " = " << a - b << std::endl;
std::cout << a << " * " << b << " = " << a * b << std::endl;
std::cout << a << " / " << b << " = " << a / 1.0 / b << std::endl;
std::cout << "Max = " << (a > b ? a : b) << std::endl;
std::cout << "Min = " << (a > b ? b : a) << std::endl;
int D = a * a - 4 * b;
if (D < 0) {
std::cout << "Нет корней" << std::endl;
} else if (0 == D) {
std::cout << "Один корень: " << -a / 2.0 << std::endl;
} else {
std::cout << "Два корня: " <<
(-a + sqrt(D)) / 2 << " и " <<
(-a - sqrt(D)) / 2 << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment