need help in this code!
How to convert the whole sentence (taken as string, with spaces) to integers!
I’ve done it in a brute force way, it doesn’t seems to work. please help!
need help in this code!
How to convert the whole sentence (taken as string, with spaces) to integers!
I’ve done it in a brute force way, it doesn’t seems to work. please help!
your code is failing because str isn’t long enough. It should be at least 550. 10^9 has 10 digits, and the spaces also account for one character.
I’m not sure about C, but in C++ you can use a stringstream, like this
https://www.codechef.com/viewsolution/32683779
Change the following part of your code:
char str[500];
fgets(str,500,stdin);
to this:
char str[1000];
fgets(str,1000,stdin);
NOTE: in this type of problems python
comes very handy as there are ready-made functions available in python
.
You can refer python
based solution: Solution In Python.
Thank you!
C++ made it so easy
Thanks bro!
but python is yet to be studied!