1)
def smm_numbers(x):
sm = 0
sm_num = 0
for _ in x:
sm += int(_)
for j in range(2, 10):
j = str(j * int(x))
for p in j:
sm_num += int(p)
if sm_num != sm:
return False
sm_num = 0
return True
a, b = map(int, input().split())
count = 0
for i in range(a, b + 1):
if smm_numbers(str(i)):
print(i)
count += 1
if count == 0:
print(0)
2)
def fib(n):
if n == 0 or n == 1:
return 1
else:
return fib(n - 1) + fib(n - 2)
for i in range(int(input())):
print(fib(i), end=' ')
3)
alphabet = ''
def now_system_10(x):
global new_system
znak = '+'
if x < 0:
x = abs(x)
znak = '-'
new_x = ''
lst = []
while x >= new_system or lst == []:
if 9 < x % new_system:
if x % new_system < 20:
lst += [alphabet[int(str(x % new_system)[1])]]
elif x % new_system < 30:
lst += [alphabet[int('1' + str(x % new_system)[1])]]
else:
lst += [alphabet[int('2' + str(x % new_system)[1])]]
else:
lst += [x % new_system]
x //= new_system
if x != 0:
lst += [x]
lst.reverse()
if znak == '-':
new_x += '-'
for j in lst:
new_x += str(j)
return new_x
num, new_system = map(int, input().split())
print(now_system_10(num))
Поделитесь своими знаниями, ответьте на вопрос:
Умоляю программисты const int* f(const int* const a)const; что обозначает каждый const?
1)
var
a, n, s: integer;
begin
write('n = ');
Readln(n);
a := 1;
while a <= n do
begin
s := s + a;
a := a + 1;
end;
writeln(s);
end.
2)
var
a, n: integer;
begin
write('n = ');
Readln(n);
a := 1;
while a <= n do
begin
writeln(2 * a);
a := a + 1;
end;
end.
3)
var
a, b: integer;
begin
write('Введите числа a и b: ');
Readln(a, b);
while a <= b do
begin
writeln(a, '^2 = ', sqr(a));
a := a + 1;
end;
end.