+ 17
Code Coach problem Mathematics
Hello guys I made this code in C++ for Mathematics and this code's runtime is so much I mean it takes long to see the output.please modify this code: https://code.sololearn.com/c6hejYxEII4x/?ref=app Edit:the problem is solved but whats the problem with mines
45 Answers
+ 10
Sample input:
12
(3*4) (3+4) (3-4) (8/2)
Sample output:
index 0
Right?
https://code.sololearn.com/cFEmiMZYr6B2/?ref=app
+ 14
Steps to be followed:
1. Take the required int/float input and in the next line take a sring input for the complete line!
2. Remove the first and the last element of the string i.e. '(' and ')' and you will get some sought of this:
str = "2+5)(3+5)(6*5)(1*2";
3. Split the string into a list by using the split function. Something like: str.split(")(");
And the new list will be: ["2+5", "3+5", .....]
4. You will get some equations that you have to evaluate (that's an easy task, tell me if you want explanation of this too)
+ 10
Namit Jain think those equations with braces as an element of an array then the (4*3) is index 1
Hope you understood
edit: the sample input have spaces
+ 10
Namit Jain
Sample Input:
15
(2+100) (5*3) (14+1)
Sample Output:
index 1
+ 9
Namit Jain Sorry for not undrrstanding you talks
Sample input:
12
(5+5) (4*3) (7+3)
Sample input:
Index 1
+ 8
Namit Jain you gave 3 inputs where index 1 is 4*3
+ 7
Gorom_Pani I put an input:
12
(8*5)(3*4)(4+3)
And it shows many errors π€
+ 7
Gorom_Pani The sample input you gave doesn't have spaces π€
And what's the output?
Index 1?
+ 7
Namit Jain damn it! Sololearn is cc test cases are showing that no output as outputπ₯π₯π₯
But your and mine code is absolutly right!?
+ 7
Gorom_Pani copy the sample input and output as it is plss π
Don't type it
Is there a space between the brackets?
+ 7
Samsil Arefeen Yes he knows it better
+ 6
Namit Jain my code is right but there is something for which its giving the output after a very long time and sometime don't even give it
But if I place the s's value after declaration and target's also the code rund perfectly!
+ 6
Namit Jain I also have done the same please check out the code I also put those equations in a list and then evaluate the strings but there must be some fishy with input please check the code
+ 6
Yes cause SL compiler needs vector size or string size typecasting but others don't want it wait lemme fix those I had fix those already but forgot to saveπ
Anyways if I fix those errors the code will take long time for output you can see
+ 6
Namit Jain now I have fix those but there shows no output while my code is right!
edit: besides i have coded this in laptop
+ 6
Namit Jain yes there is spaces
+ 6
Namit Jain you might use stringstreams for spliting
+ 6
Gorom_Pani Can you plss tell the sample output π
I am asking for it the 3rd time π’
+ 6
Gorom_Pani It is showing index 1 π€
When I put this input π€
+ 6
Gorom_Pani donno ππ’