Предмет:
ИнформатикаАвтор:
angusОтвет:
не знаю какой язык написал на питон и с++
Объяснение:
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;
}
Автор:
sariahh2ajДобавить свой ответ
Предмет:
МатематикаАвтор:
blaiseОтветов:
Смотреть
Предмет:
Қазақ тiлiАвтор:
wallyОтветов:
Смотреть
Предмет:
МатематикаАвтор:
ayannabridgesОтветов:
Смотреть