no numerals code coach failing test case 3 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

no numerals code coach failing test case 3

why is this code failing text case 3 #include <iostream> int main() { std::string input{}; std::getline(std::cin , input ); std::string num[]{"0","1","2","3","4","5","6","7","8","9","10"}; std::string word[]{"zero","one","two","three","four","five","six","seven","eight","nine","ten"}; for(int x=0; x < 11; x++){ while(input.find(num[x]) != -1){ int pos = input.find(num[x]); input.replace(pos , num[x].length() , word[x]); } } std::cout << input ; return 0; }

13th Sep 2022, 10:46 PM
D Doyen
D Doyen - avatar
2 Answers
+ 2
Think about what your code does when replacing 10.
14th Sep 2022, 2:50 AM
Shadow
Shadow - avatar
+ 2
(👉゚ヮ゚)👉 Fix your coding errors https://www.sololearn.com/compiler-playground/cb4v42687mix
14th Sep 2022, 2:30 PM
SoloProg
SoloProg - avatar