Відповідь:
C++ code:
#include <iostream>
bool check(int number){
int counter = 0;
while(number){
number /= 10;
counter++;
}
return counter >= 2;
int main(){
int input;
do{
std::cout << "Enter a number: ";
std::cin >> input;
if(check(input)){
break;
else{
std::cout << "Error" << std::endl;
while(true);
std::cout << "Answer: " << input % 10 << std::endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
C++ code:
#include <iostream>
bool check(int number){
int counter = 0;
while(number){
number /= 10;
counter++;
}
return counter >= 2;
}
int main(){
int input;
do{
std::cout << "Enter a number: ";
std::cin >> input;
if(check(input)){
break;
}
else{
std::cout << "Error" << std::endl;
}
}
while(true);
std::cout << "Answer: " << input % 10 << std::endl;
return 0;
}