• Предмет: Информатика
  • Автор: pavluksasa060
  • Вопрос задан 4 месяца назад

дано четырехзначное число верно ли что сумма его цифр больше 10 и кратно 2. верно ли что сумма первых его двух цифр больше суммы двух его последних цифр
Срочно решение нужно и ответ!!!

Ответы

Ответ дал: Fchchchv
1

Ответ:

не знаю какой язык написал на питон и с++

Объяснение:

number = int(input("Enter a four-digit number: "))

# Check if digit sum is greater than 10 and divisible by 2

digit_sum = 0

while number > 0:

digit = number % 10

digit_sum += digit

number = number // 10

if digit_sum > 10 and digit_sum % 2 == 0:

print("The digit sum is greater than 10 and divisible by 2.")

else:

print("The digit sum is not greater than 10 or not divisible by 2.")

# Check if sum of first two digits is greater than sum of last two digits

first_two_digits = number % 100

last_two_digits = number // 100

if first_two_digits > last_two_digits:

print("The sum of the first two digits is greater than the sum of the last two digits.")

else:

print("The sum of the first two digits is not greater than the sum of the last two digits.")

с++

#include <iostream>

using namespace std;

int main() {

int number;

cout << "Enter a four-digit number: ";

cin >> number;

// Check if digit sum is greater than 10 and divisible by 2

int digit_sum = 0;

while (number > 0) {

int digit = number % 10;

digit_sum += digit;

number = number / 10;

}

if (digit_sum > 10 && digit_sum % 2 == 0) {

cout << "The digit sum is greater than 10 and divisible by 2." << endl;

} else {

cout << "The digit sum is not greater than 10 or not divisible by 2." << endl;

}

// Check if sum of first two digits is greater than sum of last two digits

int first_two_digits = number % 100;

int last_two_digits = number / 100;

if (first_two_digits > last_two_digits) {

cout << "The sum of the first two digits is greater than the sum of the last two digits." << endl;

} else {

cout << "The sum of the first two digits is not greater than the sum of the last two digits." << endl;

}

return 0;

}


Fchchchv: можешь поставить лучший ответ
Вас заинтересует