int main() { int number; cout << "Enter a three-digit number: "; cin >> number;
int firstDigit = number / 100; int secondDigit = (number / 10) % 10; int thirdDigit = number % 10; bool allDigitsSame = (firstDigit == secondDigit) && (secondDigit == thirdDigit); bool anyDigitsSame = (firstDigit == secondDigit) || (secondDigit == thirdDigit) || (firstDigit == thirdDigit); if (allDigitsSame) { cout << "All digits of the number are the same." << endl; } else { cout << "All digits of the number are not the same." << endl; } if (anyDigitsSame) { cout << "There are same digits in the number." << endl; } else { cout << "There are no same digits in the number." << endl; } return 0;
using namespace std;
int main() {
int firstDigit = number / 100;int number;
cout << "Enter a three-digit number: ";
cin >> number;
int secondDigit = (number / 10) % 10;
int thirdDigit = number % 10;
bool allDigitsSame = (firstDigit == secondDigit) && (secondDigit == thirdDigit);
bool anyDigitsSame = (firstDigit == secondDigit) || (secondDigit == thirdDigit) || (firstDigit == thirdDigit);
if (allDigitsSame) {
cout << "All digits of the number are the same." << endl;
} else {
cout << "All digits of the number are not the same." << endl;
}
if (anyDigitsSame) {
cout << "There are same digits in the number." << endl;
} else {
cout << "There are no same digits in the number." << endl;
}
return 0;
}