Укажите минимальное натуральное число, при вводе которого этот алгоритм напечатает сначала 2 потом 2 .


Pascal


var x, a, b: longint;

begin

readln(x);

a := 0; b := 0;

while x > 0 do begin

if x mod 2 = 0 then

a := a + x mod 7

else

b := b + 1;

x := x div 7;

end;

writeln(a); write(b);

end.

C++


#include

using namespace std;

int main()

{

int x, a, b;

cin >> x;

a = 0; b = 0;

while (x > 0) {

if (x%2 == 0) a = a + x % 7;

else b = b + 1;

x = x / 7;

}

cout << a << endl << b;

return 0;

}

Python


x = int(input())

a=0; b=0

while x > 0:

if x%2 == 0:

a = a + x % 7

else:

b = b + 1

x = x // 7

print(a, b)
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.