Программы на C++. Форум разработчиков
-
Anonymous
Как заставить cin принимать только числа
Сообщение
Anonymous »
Вот код
Код: Выделить всё
double enter_number()
{
double number;
while(1)
{
cin>>number;
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits::max(), '\n');
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/10828937/how-to-make-cin-take-only-numbers[/url]
1736799178
Anonymous
Вот код
[code]double enter_number()
{
double number;
while(1)
{
cin>>number;
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits::max(), '\n');
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/10828937/how-to-make-cin-take-only-numbers[/url]