0
Code coach , balacon
At this code Why num doesnt take all the input values within the loop ?. https://code.sololearn.com/cPDWn3Y2NU9Y/?ref=app
7 ответов
+ 2
Why are you reading integers where the task says input are two comma separated string?
Neither <parta> nor <partb> were initialized, they might contain garbage values
You SHOULD NOT print anything except for what the task had asked you to. I see you print values of <num> and <i> inside the loop (line 27)
+ 2
Dark the input formats are different between the two problems. Try something like scanf("%f,%f", ...).
+ 2
Dark the first parameter in scanf is called the format specifier. It serves as a sort hint of the format that scanf should find on the input line. In this case, it is two floating point numbers with a comma between. (I believe "%f,%f" would work even if the input had extra spaces in the middle). It is not as smart as a Regular Expressions interpreter, so sometimes you have to take an input string and parse it in your own code. You can search the web for scanf format specifiers to see some of the details.
0
Ipang
I print them to see what input the code takes
Not the final code
Also
I tried to take strings as input and turn it to integers to compare them and failed , so tried to take it like that
0
Brian
I didnt know that i can put "," on scanf to ignore it
I tried hard to take the input without ','
Tried excluded the input itself
And also tried to store it as an element in array and then exclude it
But didnt know that scanf itself can do this 😐
And the code Workd !
Would u please explain it how ?
0
Dark
"I print them to see what input the code takes
Not the final code"
Actually coach judges don't care about that, you fail if your code outputs anything out of the requirement.
"Also I tried to take strings as input and turn it to integers to compare them and failed, so tried to take it like that"
I see, however as per the coach statement, two inputs will be fed in for the code, not four.