Is there another way ? | Sololearn: Learn to code for FREE!


Is there another way ?

for this code is there another way to don't request length of the input from user and limit the loop (to don't results timelimit exceed) ?

5/28/2018 2:28:17 PM


2 Answers

New Answer


Input a string instead. Use a for each loop to do the conversion, or whatever the loop contents are. std::string v; std::cin >> v; for (char i : v) { // your stuff. } // or for (int i = 0; i < v.length(); i++) { // your stuff. } C++ STL ( <algorithm> ) also has std::transform and ::tolower, which you can use to convert a string to lowercase, if you don't want to manually do the conversion. std::transform(v.begin(), v.end(), v.begin(), ::tolower);