+ 5
[Solved] Debugging help
Hey, I'm writing a C++ program to solve the Daily Teaser asked by SoloLearn but seem to have hit a dead end. I have eradicated all compile time errors but the output is very absurd. Please help. https://code.sololearn.com/cCmtM2RAo896/?ref=app
9 Respuestas
+ 5
Bad_Bit Works good. Solves the problem.
But the thing is I was trying to make the code dynamic.
For example,
Input: 10, 3, 2
Logic: 10^2 + 3^2 + 2^2 = 113
Output: 113
So the code should be able to read multiple digits and multiple numbers.
Also, sstream::stringstream is used to convert string to integer. Refer: https://www.geeksforgeeks.org/converting-strings-numbers-cc/amp/
+ 8
It's very complex
Temp is not initialised
And you are indexing it with [0]
So make temp a string of length equal to how many digits you want in number
For 1 digit number
temp = "0" ; //put anything
+ 8
Also your loop will not calculate the second number it skips it
+ 8
Ok
+ 8
Updated please don't use spaces use "," for separation
https://code.sololearn.com/cF592tOQmpLZ/?ref=app
+ 7
Ok I made it for two numbers and single digits I will update it
+ 6
Bad_Bit Thank you.
+ 4
Bad_Bit If you don't mind, could you please debug the code. I am not sure how to go further.