45 AnswersNew Answer
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
9/23/2020 6:49:03 AMGorom_Pani
45 AnswersNew Answer
Sample input: 12 (3*4) (3+4) (3-4) (8/2) Sample output: index 0 Right? https://code.sololearn.com/cFEmiMZYr6B2/?ref=app
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)
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
Namit Jain Sample Input: 15 (2+100) (5*3) (14+1) Sample Output: index 1
Namit Jain Sorry for not undrrstanding you talks Sample input: 12 (5+5) (4*3) (7+3) Sample input: Index 1
Namit Jain you gave 3 inputs where index 1 is 4*3
Gorom_Pani I put an input: 12 (8*5)(3*4)(4+3) And it shows many errors 🤔
Gorom_Pani The sample input you gave doesn't have spaces 🤔 And what's the output? Index 1?
Namit Jain damn it! Sololearn is cc test cases are showing that no output as output😥😥😥 But your and mine code is absolutly right!?
Gorom_Pani copy the sample input and output as it is plss 🙏 Don't type it Is there a space between the brackets?
Samsil Arefeen Yes he knows it better
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!
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
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
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
Namit Jain yes there is spaces
Namit Jain you might use stringstreams for spliting
Gorom_Pani Can you plss tell the sample output 😐 I am asking for it the 3rd time 😢
Gorom_Pani It is showing index 1 🤔 When I put this input 🤔
Gorom_Pani donno 😐😢
Learn Playing. Play Learning
SoloLearn Inc.4 Embarcadero Center, Suite 1455
Send us a message