From c9539b8324174c52e6f10fc11922bc524c764a4a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Sep 2022 18:13:46 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=BE=D0=BB=D1=8C=D1=81=D0=BA=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BB=D1=8C=D0=BA=D1=83=D0=BB=D1=8F=D1=82=D0=BE?= =?UTF-8?q?=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- польский калькулятор.txt | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 польский калькулятор.txt diff --git a/польский калькулятор.txt b/польский калькулятор.txt new file mode 100644 index 0000000..2ae907f --- /dev/null +++ b/польский калькулятор.txt @@ -0,0 +1,41 @@ +#include + +using namespace std; + +int main() +{ + string str; + getline(cin, str); + vector sym; + vector ans; + int a; + for (int i = 0; i < str.size(); i++){ + if (str[i] != ' ') { + sym.push_back(str[i]); + } + } + for (int i = 0; i < sym.size(); i++) { + if ('0' <= sym[i] && sym[i] <= '9') { + ans.push_back(sym[i] - '0'); + } + if (sym[i] == '+') { + a = ans[ans.size() - 1]; + ans.pop_back(); + ans[ans.size() - 1] += a; + } + if (sym[i] == '-') { + a = ans[ans.size() - 1]; + ans.pop_back(); + ans[ans.size() - 1] -= a; + } + if (sym[i] == '*') { + a = ans[ans.size() - 1]; + ans.pop_back(); + ans[ans.size() - 1] *= a; + } + } + for (int i = 0; i < ans.size(); i++) + cout << ans[i] << ' '; + + return 0; +} \ No newline at end of file -- 2.36.2 From 57b96db8004457036e66b0c1ca32a82f35057ef2 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Sep 2022 18:19:20 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=AD=D1=82=D0=BE=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BB=D0=B8=D1=87=D0=B8=D1=8F=20=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- удаление пробелов.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 удаление пробелов.txt diff --git a/удаление пробелов.txt b/удаление пробелов.txt new file mode 100644 index 0000000..9782656 --- /dev/null +++ b/удаление пробелов.txt @@ -0,0 +1,26 @@ +#include + +using namespace std; + +int main() +{ + string str; + getline(cin, str); + int flag = 0; + for (int i = 0; i < str.size(); i++){ + if (str[i] != ' ') { + cout << str[i]; + flag = 1; + } + if (str[i] == ' ' && flag == 0) { + continue; + } + if (str[i] == ' ' && i+1 < str.size() && flag == 1) { + if (str[i+1] != ' ') { + cout << str[i]; + } + } + } + + return 0; +} \ No newline at end of file -- 2.36.2