From e1e44b141465de824c6ee0effe92bb16a65e0878 Mon Sep 17 00:00:00 2001 From: Rv_Sp Date: Thu, 5 Dec 2024 13:57:14 +0300 Subject: [PATCH] command --- 2-3-b.spp | 16 +++++++++++++ 2-3-c.spp | 21 +++++++++++++++++ 2-3-d.spp | 0 2-3-e.spp | 31 +++++++++++++++++++++++++ 2-3-f.spp | 12 ++++++++++ 2-3-g.spp | 12 ++++++++++ 2-4-a.spp | 39 +++++++++++++++++++++++++++++++ 2-4-b.spp | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2-4-c.spp | 24 +++++++++++++++++++ 2-4-d.spp | 19 +++++++++++++++ 2-4-e.spp | 32 ++++++++++++++++++++++++++ 2-7-a.spp | 32 ++++++++++++++++++++++++++ 12 files changed, 307 insertions(+) create mode 100644 2-3-b.spp create mode 100644 2-3-c.spp create mode 100644 2-3-d.spp create mode 100644 2-3-e.spp create mode 100644 2-3-f.spp create mode 100644 2-3-g.spp create mode 100644 2-4-a.spp create mode 100644 2-4-b.spp create mode 100644 2-4-c.spp create mode 100644 2-4-d.spp create mode 100644 2-4-e.spp create mode 100644 2-7-a.spp diff --git a/2-3-b.spp b/2-3-b.spp new file mode 100644 index 0000000..12de1d5 --- /dev/null +++ b/2-3-b.spp @@ -0,0 +1,16 @@ +#include + +int main() +{ + int x, y, z; + std::cin >> x >> y >> z; + if(x + y <= z || x + z <= y || z + y <= x){ + std::cout << "UNDEFINED "; + return 0; + } + if (y * y + z * z == x * x || x * x + z * z == y * y || y * y + x * x == z * z){ + std::cout << "YES "; + return 0; + } + std::cout << "NO "; +} diff --git a/2-3-c.spp b/2-3-c.spp new file mode 100644 index 0000000..a8bf920 --- /dev/null +++ b/2-3-c.spp @@ -0,0 +1,21 @@ + +#include +int main() +{ + int a; + std::cin >> a; + if(a % 400 == 0 ){ + std::cout << "YES"; + return 0 ; + } + else if(a % 100 == 0 ) { + std::cout << "NO"; + return 0 ; + } + else if(a % 4 == 0) { + std::cout << "YES"; + return 0 ; + } + std::cout << "NO"; + +} \ No newline at end of file diff --git a/2-3-d.spp b/2-3-d.spp new file mode 100644 index 0000000..e69de29 diff --git a/2-3-e.spp b/2-3-e.spp new file mode 100644 index 0000000..75960ed --- /dev/null +++ b/2-3-e.spp @@ -0,0 +1,31 @@ +#include +#include +int main() +{ + int a, b; + std::cin >> a >> b; + int e = a; + std::cout.width(a); + for(int k = 1; k < a; k++) { + std::cout <<" "; + if (a >= 3 && k == 1){ + std::cout <<" "; + } + else if(a < 3){ + std::cout <<" "; + } + + } + for(int i = 1; i <= b; i++) { + std::cout.width(3); + std::cout << i; + if (e == 7){ + std::cout << "\n"; + e = 1; + } + else{ + e++; + } + } + +} \ No newline at end of file diff --git a/2-3-f.spp b/2-3-f.spp new file mode 100644 index 0000000..70e5c70 --- /dev/null +++ b/2-3-f.spp @@ -0,0 +1,12 @@ +#include + +int main() { + int a,b = 0; + std::cin >> a; + for(;a != 0;) { + b += a % 10; + a /= 10; + } + + std::cout << b << "\n"; +} \ No newline at end of file diff --git a/2-3-g.spp b/2-3-g.spp new file mode 100644 index 0000000..436eef6 --- /dev/null +++ b/2-3-g.spp @@ -0,0 +1,12 @@ +#include +int main() { + int a; + std::cin >> a; + double b = 1; + double c = 0.0; + for (int i = 1; i <= a; ++i) { + c += b / i; + b = -b; + } + std::cout << c << "\n"; +} \ No newline at end of file diff --git a/2-4-a.spp b/2-4-a.spp new file mode 100644 index 0000000..a5f01b3 --- /dev/null +++ b/2-4-a.spp @@ -0,0 +1,39 @@ +#include +#include + +bool IsGood(const std::string& pas) { + if (pas.size() < 8 || pas.size() >14) { + return false; + } + int a = 0; + int b = 0; + int x = 0; + int d = 0; + + for (char c : pas) { + if (c < 33 || c > 126) { + return false; + } + if ('A' <= c && c <= 'Z') { + a = 1; + } else if ('a' <= c && c <= 'z') { + b = 1; + } else if ('0' <= c && c <= '9') { + x = 1; + } else { + d = 1; + } + } + + return (a + b + x + d >= 3); +} + +int main() { + std::string pas; + std::getline(std::cin, pas); + if (IsGood(pas)) { + std::cout << "YES\n"; + } else { + std::cout << "NO\n"; + } +} \ No newline at end of file diff --git a/2-4-b.spp b/2-4-b.spp new file mode 100644 index 0000000..d728bbc --- /dev/null +++ b/2-4-b.spp @@ -0,0 +1,69 @@ +#include +#include + +int main() +{ +std::string clovo; +std::string a; +std::cin >> clovo; +a.push_back(clovo[0]); +for (size_t i = 1; i != clovo.size(); ++i) { + char c = clovo[i]; + switch (c) { + case 'b': + case 'f': + case 'p': + case 'v': + c = '1'; + if (a.back() != c) { + a.push_back(c); + } + break; + case 'c': + case 'g': + case 'j': + case 'k': + case 'q': + case 's': + case 'x': + case 'z': + c = '2'; + if (a.back() != c) { + a.push_back(c); + } + break; + case 'd': + case 't': + c = '3'; + if (a.back() != c) { + a.push_back(c); + } + break; + case 'l': + c = '4'; + if (a.back() != c) { + a.push_back(c); + } + break; + case 'm': + case 'n': + c = '5'; + if (a.back() != c) { + a.push_back(c); + } + break; + case 'r': + c = '6'; + if (a.back() != c) { + a.push_back(c); + } + break; + } + } + while (a.size() < 4) { + a.push_back('0'); + } + a.resize(4); + std::cout << a; + +} \ No newline at end of file diff --git a/2-4-c.spp b/2-4-c.spp new file mode 100644 index 0000000..79d7faf --- /dev/null +++ b/2-4-c.spp @@ -0,0 +1,24 @@ +#include +#include + +int main() +{ + std::vector data; + std::vector dataT; + int a; + std::cin>> a; + for(int i = 0;i < a;i++){ + int b; + std::cin >> b; + data.push_back(b); + dataT.push_back(i); + } + for(int j = 0;j < a;j++){ + dataT[data[j] - 1] = j + 1; + } + for(int k = 0 ;k< a;k++){ + std::cout << dataT[k]<<' '; + } + + +} \ No newline at end of file diff --git a/2-4-d.spp b/2-4-d.spp new file mode 100644 index 0000000..39f79f6 --- /dev/null +++ b/2-4-d.spp @@ -0,0 +1,19 @@ +#include +#include +#include +#include + +int main() { + std::vector a; + + std::string b; + while (std::getline(std::cin, b)) { + a.push_back(b); + } + + std::sort(a.rbegin(), a.rend()); + + for (size_t i = 0; i != a.size(); ++i) { + std::cout << a[i] << "\n"; + } +} \ No newline at end of file diff --git a/2-4-e.spp b/2-4-e.spp new file mode 100644 index 0000000..c687528 --- /dev/null +++ b/2-4-e.spp @@ -0,0 +1,32 @@ +#include +#include +#include + +int main() { + std::string clovo; + std::getline(std::cin, clovo); + + int a = 0; + int b = clovo.size() - 1; + bool yesOrNo = true; + + while (a < b) { + if (clovo[a] == ' ') { + ++a; + } else if (clovo[b] == ' ') { + --b; + } else if (clovo[a] != clovo[b]) { + yesOrNo = false; + break; + } else { + ++a; + --b; + } + } + + if (yesOrNo) { + std::cout << "YES\n"; + } else { + std::cout << "NO\n"; + } +} \ No newline at end of file diff --git a/2-7-a.spp b/2-7-a.spp new file mode 100644 index 0000000..c687528 --- /dev/null +++ b/2-7-a.spp @@ -0,0 +1,32 @@ +#include +#include +#include + +int main() { + std::string clovo; + std::getline(std::cin, clovo); + + int a = 0; + int b = clovo.size() - 1; + bool yesOrNo = true; + + while (a < b) { + if (clovo[a] == ' ') { + ++a; + } else if (clovo[b] == ' ') { + --b; + } else if (clovo[a] != clovo[b]) { + yesOrNo = false; + break; + } else { + ++a; + --b; + } + } + + if (yesOrNo) { + std::cout << "YES\n"; + } else { + std::cout << "NO\n"; + } +} \ No newline at end of file