По разделам

 

Решение задачи Integer 7


Дано двузначное число. Найти сумму и произведение его цифр.

Код (C/C++)

#include <iostream>
using namespace std;
int main(){
	int n, f, s;
	cout << "Enter the number N: ";
	cin >> n;
	f = int(n/10);
	s = n%10;
	cout << "Sum of the digits: " << f+s << endl;
	cout << "Product of the digits: " << f*s;
	return 0;
}

Код (Python)

import random

N = random.randrange(10,100)
print("N = ", N)
d1 = int(N/10)
d0 = N%10
print("Tens: ", d1)
print("Units: ", d0)
print("Sum: ", d1+d0)
print("Product: ", d1*d0)
									

Код (Pascal)

program Integer7;
var
  A, Res: Integer;
begin
  Write('Введите двузначное число: ');
  Readln(A);
  Res:=(A div 10) + (A mod 10);
  Writeln('Сумма его цифр равна: ',Res);
  Res:=(A div 10) * (A mod 10);
  Writeln('Произведение его цифр равно: ',Res);
end.
									




Integer. Абрамян
Integer 1 Просмотров: 11700
Integer 2 Просмотров: 7427
Integer 3 Просмотров: 7806
Integer 4 Просмотров: 35917
Integer 5 Просмотров: 8335
Integer 6 Просмотров: 6838
Integer 7 Просмотров: 6665
Integer 8 Просмотров: 5366
Integer 9 Просмотров: 4475
Integer 10 Просмотров: 6104
Integer 11 Просмотров: 6412
Integer 12 Просмотров: 6864
Integer 13 Просмотров: 6404
Integer 14 Просмотров: 3409
Integer 15 Просмотров: 4330
Integer 16 Просмотров: 3540
Integer 17 Просмотров: 3815
Integer 18 Просмотров: 3487
Integer 19 Просмотров: 5318
Integer 20 Просмотров: 4049
Integer 21 Просмотров: 4394
Integer 22 Просмотров: 3588
Integer 23 Просмотров: 4451
Integer 24 Просмотров: 8301
Integer 25 Просмотров: 3529
Integer 26 Просмотров: 3172
Integer 27 Просмотров: 2926
Integer 28 Просмотров: 3644
Integer 29 Просмотров: 4993
Integer 30 Просмотров: 4551

Комментарии

Чтобы написать комментарии вам нужно войти в систему или зарегистрироваться



Заявка на расчет