+ 2
Use `find` method to get the index of decimal point and use it with `substr` method to "split" the string in two, before converting to `int` using `stoi`. https://code.sololearn.com/c2PLHNpah7bN/?ref=app
22nd Feb 2022, 12:57 PM
Ipang
+ 1
The problem is in your first ā€œforā€ loop. You are trying to copy a string to an int array. When you have ā€œarr[i]=str[i]ā€, this doesn’t assign the digit you want to arr. Try debugging by using cout << str[i] << ā€œ ā€œ << arr[i] or something in that loop and you’ll see what I mean. So you need to figure out how to extract a digit from a string.
23rd Feb 2022, 3:18 PM
JRS
JRS - avatar
0
Hi šŸ‘‹ Manav, https://code.sololearn.com/clEPPvKmo43O/?ref=app just some problems in your code, like the declaration of arr2..
22nd Feb 2022, 12:51 PM
Amine Laaboudi
Amine Laaboudi - avatar