ответ:A№1
mass = [int(input()) for i in range(5)]
for i in mass:
if i % 3 == 0 and i % 10 == 8:
print(i, end=' ')
№2
from random import randint
mass = [randint(100, 999) for i in range(100, 1000)]
for i in range(len(mass) - 1):
for j in range(i + 1, len(mass)):
if mass[i] % 100 > mass[j] % 100:
mass[i], mass[j] = mass[j], mass[i]
print(mass)
№3
mass = [randint(0, 1000) for i in range(1000)]
if mass[i] == mass[-1]:
B№1
k = 0
if str(i)[0] == '8':
k += 1
print(k)
if sum(map(int, str(mass[j]))) < sum(map(int, str(mass[i]))):
k = mx = 0
for i in range(1, len(mass)):
if mass[i] * mass[k] > mx:
mx = mass[i] * mass[k]
max_i, max_k = i, k
print(max_k, max_i)
Объяснение:
не знаю сколько чисел должно быть в массиве в интервале от 0, 1000
если надо изменить, то поменять в range(1000) на нужное кол-во чисел
#include <iostream>
using namespace std;
int main(){
char c1, s1, c2, s2;
cin >> c1;
cin >> s1;
cin >> c2;
cin >> s2;
bool colComp (c1 - c2 <= 1 && c1 - c2 >= -1), strComp (s1 - s2 <= 1 && s1 - s2 >= -1);
if (c1 == c2 && s1 == s2){
cout << "NO";
}
else if (colComp && strComp){
if (c1 <= 0 || s1 <= 0 || c2 <= 0 || s2 <= 0){
else {cout << "YES";}
else {cout << "NO";}
return 0;
ответ:A№1
mass = [int(input()) for i in range(5)]
for i in mass:
if i % 3 == 0 and i % 10 == 8:
print(i, end=' ')
№2
from random import randint
mass = [randint(100, 999) for i in range(100, 1000)]
for i in range(len(mass) - 1):
for j in range(i + 1, len(mass)):
if mass[i] % 100 > mass[j] % 100:
mass[i], mass[j] = mass[j], mass[i]
print(mass)
№3
from random import randint
mass = [randint(0, 1000) for i in range(1000)]
for i in range(len(mass) - 1):
if mass[i] == mass[-1]:
print(i, end=' ')
B№1
mass = [int(input()) for i in range(5)]
k = 0
for i in mass:
if str(i)[0] == '8':
k += 1
print(k)
№2
from random import randint
mass = [randint(100, 999) for i in range(100, 1000)]
for i in range(len(mass) - 1):
for j in range(i + 1, len(mass)):
if sum(map(int, str(mass[j]))) < sum(map(int, str(mass[i]))):
mass[i], mass[j] = mass[j], mass[i]
print(mass)
№3
from random import randint
mass = [randint(0, 1000) for i in range(1000)]
print(mass)
k = mx = 0
for i in range(1, len(mass)):
if mass[i] * mass[k] > mx:
mx = mass[i] * mass[k]
max_i, max_k = i, k
k += 1
print(max_k, max_i)
Объяснение:
не знаю сколько чисел должно быть в массиве в интервале от 0, 1000
если надо изменить, то поменять в range(1000) на нужное кол-во чисел
#include <iostream>
using namespace std;
int main(){
char c1, s1, c2, s2;
cin >> c1;
cin >> s1;
cin >> c2;
cin >> s2;
bool colComp (c1 - c2 <= 1 && c1 - c2 >= -1), strComp (s1 - s2 <= 1 && s1 - s2 >= -1);
if (c1 == c2 && s1 == s2){
cout << "NO";
}
else if (colComp && strComp){
if (c1 <= 0 || s1 <= 0 || c2 <= 0 || s2 <= 0){
cout << "NO";
}
else {cout << "YES";}
}
else {cout << "NO";}
return 0;
}
Объяснение: