This commit is contained in:
Rv_Sp 2024-12-05 13:57:14 +03:00
parent bd3bcf2fec
commit e1e44b1414
12 changed files with 307 additions and 0 deletions

16
2-3-b.spp Normal file
View File

@ -0,0 +1,16 @@
#include <iostream>
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 ";
}

21
2-3-c.spp Normal file
View File

@ -0,0 +1,21 @@
#include <iostream>
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";
}

0
2-3-d.spp Normal file
View File

31
2-3-e.spp Normal file
View File

@ -0,0 +1,31 @@
#include <iostream>
#include <string>
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++;
}
}
}

12
2-3-f.spp Normal file
View File

@ -0,0 +1,12 @@
#include <iostream>
int main() {
int a,b = 0;
std::cin >> a;
for(;a != 0;) {
b += a % 10;
a /= 10;
}
std::cout << b << "\n";
}

12
2-3-g.spp Normal file
View File

@ -0,0 +1,12 @@
#include <iostream>
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";
}

39
2-4-a.spp Normal file
View File

@ -0,0 +1,39 @@
#include <iostream>
#include <string>
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";
}
}

69
2-4-b.spp Normal file
View File

@ -0,0 +1,69 @@
#include <iostream>
#include <string>
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;
}

24
2-4-c.spp Normal file
View File

@ -0,0 +1,24 @@
#include <iostream>
#include <vector>
int main()
{
std::vector<int> data;
std::vector<int> 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]<<' ';
}
}

19
2-4-d.spp Normal file
View File

@ -0,0 +1,19 @@
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main() {
std::vector<std::string> 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";
}
}

32
2-4-e.spp Normal file
View File

@ -0,0 +1,32 @@
#include <iostream>
#include <string>
#include <vector>
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";
}
}

32
2-7-a.spp Normal file
View File

@ -0,0 +1,32 @@
#include <iostream>
#include <string>
#include <vector>
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";
}
}