Дано трехзначное число. Определить, какая из его цифрбольше:а) первая или последняя;б) первая или вторая;в) вторая или последняя. РЕШИТЬ на Visual Studio

28 Мар 2021 в 19:44
192 +1
0
Ответы
1
include

int main() {
int number;
std::cout << "Enter a three-digit number: ";
std::cin >> number;

int firstDigit = number / 100;
int secondDigit = (number % 100) / 10;
int thirdDigit = number % 10;
if (firstDigit > thirdDigit) {
std::cout << "The first digit is greater than the last digit." << std::endl;
}
else if (firstDigit < thirdDigit) {
std::cout << "The last digit is greater than the first digit." << std::endl;
}
else {
std::cout << "The first and last digits are equal." << std::endl;
}
if (firstDigit > secondDigit) {
std::cout << "The first digit is greater than the second digit." << std::endl;
}
else if (firstDigit < secondDigit) {
std::cout << "The second digit is greater than the first digit." << std::endl;
}
else {
std::cout << "The first and second digits are equal." << std::endl;
}
if (secondDigit > thirdDigit) {
std::cout << "The second digit is greater than the last digit." << std::endl;
}
else if (secondDigit < thirdDigit) {
std::cout << "The last digit is greater than the second digit." << std::endl;
}
else {
std::cout << "The second and last digits are equal." << std::endl;
}
return 0;

}

17 Апр 2024 в 20:02
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир