Дано трехзначное число. Определить, какая из его цифрбольше:а) первая или последняя;б) первая или вторая;в) вторая или последняя. РЕШИТЬ на Visual Studio
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;
int main() {
int firstDigit = number / 100;int number;
std::cout << "Enter a three-digit number: ";
std::cin >> number;
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;
}