From fa79441e4722e3c4ab235956ac0a0868cc6314e0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 28 May 2026 19:31:27 +0300 Subject: [PATCH] add new demo file calculator c++/l5.cpp --- c++/l5.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 c++/l5.cpp diff --git a/c++/l5.cpp b/c++/l5.cpp new file mode 100644 index 0000000..45feaf4 --- /dev/null +++ b/c++/l5.cpp @@ -0,0 +1,38 @@ +#include +#include + +int main() { + int s = 0; + while(s <= 3) { + std::string pol; + std::cout << "Знак" << std::endl; + std::cin >> pol; + double x1; + std::cout << "Первое число" << std::endl; + std::cin >> x1; + double x2; + std::cout << "Второе число" << std::endl; + std::cin >> x2; + if(pol == "+") { + std::cout << x1 << pol << x2 << "=" << x1+x2 << std::endl; + s++; + } + else if(pol == "-") { + std::cout << x1 << pol << x2 << "=" << x1-x2 << std::endl; + s++; + } + else if(pol == "*") { + std::cout << x1 << pol << x2 << "=" << x1*x2 << std::endl; + s++; + } + else if(pol == "/") { + std::cout << x1 << pol << x2 << "=" << x1/x2 << std::endl; + s++; + } + else { + std::cout << "Неверный знак" << std::endl; + return 0; + } + } + return 0; +}