Проблема повтора при некорректном вводе / Retry problem when entering incorrectly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Проблема повтора при некорректном вводе / Retry problem when entering incorrectly

Если в int при cin ввести не число то в while или for будет бесконечный вывод пропуская cin (я пока не знаю на сколько всё запутано) в краткости: что делать если вводится не корректный символ для некоторого семейства как перевести его в корректный я на 100% уверен что ничего не понятно но думаю вы и сами с этим сталкивались так что поймёте увидев код. If you enter a non-number in int with cin, then in while or for there will be endless output skipping cin (I don’t know how confusing everything is yet) in short: what to do if an incorrect symbol is entered for of some family, how to translate it into the correct one, I’m 100% sure that nothing is clear, but I think you’ve encountered this yourself, so you’ll understand when you see the code. https://sololearn.com/compiler-playground/cYZ39exOIscG/?ref=app

3rd Jan 2024, 4:25 PM
Gfy Hgfh
12 Answers
3rd Jan 2024, 7:02 PM
🇮🇱 Radin Masiha 🇮🇱
🇮🇱 Radin Masiha 🇮🇱 - avatar
+ 2
Оооо спасибо если я правильно понял это будет то что надо Oooh thank you if I understood correctly this will be what I need
3rd Jan 2024, 7:10 PM
Gfy Hgfh
+ 1
This is not because you entered non-integer. That's because you said while(0==0). This means that a loop that do sth until 0 != 0. So this will continue forever, because 0 is always 0 and nothing can cause it to be unequal.
3rd Jan 2024, 4:33 PM
🇮🇱 Radin Masiha 🇮🇱
🇮🇱 Radin Masiha 🇮🇱 - avatar
0
Я это сделал это для того чтобы цикл был вечен я сейчас покажу код который я попытался сделать от скуки честно говоря / I did this so that the loop would be eternal, I’ll now show you the code that I tried to do out of boredom, to be honest
3rd Jan 2024, 4:48 PM
Gfy Hgfh
0
Только не суди строго я только начал делать что-то в программирование / Just don't judge strictly, I just started doing something in programming
3rd Jan 2024, 4:50 PM
Gfy Hgfh
0
Но он не сработает в этом приложении
3rd Jan 2024, 4:52 PM
Gfy Hgfh
0
But it won't work in this application
3rd Jan 2024, 4:53 PM
Gfy Hgfh
0
No I won't judge you, maybe I was the same as you when I started programming, you'll grow and get better when you practice Anyway, I don't know is your problem solved or no, I don't know what is your problem? What exactly do you want to do?
3rd Jan 2024, 5:35 PM
🇮🇱 Radin Masiha 🇮🇱
🇮🇱 Radin Masiha 🇮🇱 - avatar
0
Попытаюсь объяснить как смогу. мне надо чтобы если введённая переменная не поддерживается типом данных чтобы она заменялась или не вставлялась в строчную переменную I'll try to explain as best I can. I need that if the entered variable is not supported by the data type, it should be replaced or not inserted into a string variable
3rd Jan 2024, 6:23 PM
Gfy Hgfh
0
Welcome, I've used exception handling to check whether the input data is convertable using "stoi" (string to integer) method and print the number. Exception handling is covered in the last module of C++ course.
3rd Jan 2024, 8:23 PM
🇮🇱 Radin Masiha 🇮🇱
🇮🇱 Radin Masiha 🇮🇱 - avatar
0
Привет, проблема здесь в компиляторе сололёрна, а так же в некоторых других компиляторах которые есть для андроида. Они не умеют принимать ввод несколько раз в процессе выполнения программы. https://play.google.com/store/apps/details?id=com.kvassyu.coding2.cpp Этот компилятор работает с твоей программой как нужно, но управление консолью в Андроиде тоже отличается от консоли Виндоус. Цлс тут не работает, да и вообще консоль андроид, похоже, нельзя очистить никак, только вводом пустых строк, чтобы весь предыдущий ввод ушёл из области видимости. Удачи.
4th Jan 2024, 5:31 AM
Сергей Лансков
Сергей Лансков - avatar