Ralph
Yeah i've removed the = 0 and it's the same time 👌🏿 thanks
Ralph
Is there anything else i can do for it?
Igor🇺🇦
I have a function above for divide and conquer, and that function i sent is for the exhaustive result
That does not explain what are you doing in the function. What does it mean brute sum? What are you calculating?
Ralph
I am trying to get the maximum sub array sum in 2 tries. The first is divide and conquer, and the second (which i sent) is a brute calculation for it
Igor🇺🇦
I have a function above for divide and conquer, and that function i sent is for the exhaustive result
Is this the problem you're trying to solve https://en.wikipedia.org/wiki/Maximum_subarray_problem?
Ralph
Is this the problem you're trying to solve https://en.wikipedia.org/wiki/Maximum_subarray_problem?
Yes but i guess here they are doing it by divide and conquer. I've written the code for the brute but it is taking a hell of time
Igor🇺🇦
Ralph
So it should be like that?
Ralph
Or is there a way to make it in O(N)
Igor🇺🇦
Or is there a way to make it in O(N)
It's in the link - Kadane's algorithm
Ralph
I will check it
Ralph
Thank youu
Anonymous
While I'm running the code in visuval stidio code I'm getting an error ' vscanf enterrupted'
Anonymous
Can any one allow me to send the problem by video ?
Manish
HI , Is there any alternatives for <sys/time.h> in windows?
Manish
or something else which works on cross platform?
Georges
Hello. How can i implement a function that returns the maximum possible profit but using divide and conquer. I have to use templates so the parameters should be Iter start and Iter end only
Anonymous
1) ctime 2) std::chrono
Nooo, no ctime while there's chrono
Vlad
Nooo, no ctime while there's chrono
He didn't specified his programming language. Maybe he's got C
Anonymous
/warn @TU_NaoL PMing
Thailand import
Hello, how to create a calculator that can use any arithmetic operator in the same time? For example, calculate 2+6-1*8/9
Thailand import
Because, what I find in Google is only show all those simple calculator. I knew that
Anonymous
Hello, how to create a calculator that can use any arithmetic operator in the same time? For example, calculate 2+6-1*8/9
math expression parser https://gist.github.com/Raincode/e5115669bb647ceba690252ed39445f8
Thailand import
Not C++, forget to tell sorry
Anonymous
Using C
write yourself x)
Thailand import
I dkk that why Im asking 😂😂
Ehsan
https://stackoverflow.com/questions/31104531/calculator-in-c-using-stack
Thailand import
Oh tq Bro🙏
Anonymous
Using C
Data structures and Algorithms Stack - Operator precedence, Infix, postfix Learn it.
Anonymous
You can use that to create a calculator in C
Thailand import
Okk
Thailand import
Tqtq
Abhishek
👍
L@L@JI
Yes
Amulya Mohan
Ye thank you
M
Hi , how can be resolve a domain with defined dns server in c code ?
Thailand import
Data structures and Algorithms Stack - Operator precedence, Infix, postfix Learn it.
Hmm Bro, only use switch and case can create mix operator calculator?
Pavel
Hmm Bro, only use switch and case can create mix operator calculator?
If you want it to process operations in the correct mathematical order you probably need something like abstract syntax tree
Thailand import
If you want it to process operations in the correct mathematical order you probably need something like abstract syntax tree
I don't understand that 😢 I saw someone send the link, but still cannot get what it mean
Thailand import
Simple calculator only I can make it🤕
Manish
Hi, Is there anything equivalent to release() for a raw pointer?
Ralph
Does anyone know why how to fix the error "Non-Void function does not return a value in all control path"
Ralph
It contains
Ralph
That's what is disturbing
Артём
Every branch of your if-operators should contain return.
I mean, there should not be any path to exit function without return .
Ralph
I still have the error
Ralph
If i add a return after my if { return expression;} it works
Ralph
But i have 3 if's with each a return and i have the error at the closing bracket of the function
Igor🇺🇦
I still have the error
No one can help without your code. The error is clear.
Артём
I still have the error
we cannot guess not having seen your code.
Ralph
I will send 2sec
Ralph
int peak(std::vector<int>& v, int start, int end) { int middle = (start + end) / 2; if ((v[middle] >= v[middle - 1]) && (v[middle] >= v[middle + 1])) { return middle; } if (v[middle] < v[middle - 1]) { return peak(v, start, middle - 1); } if (v[middle] < v[middle + 1]) { return peak(v, middle + 1, end); } }
Vlad
Of course it would
You must have a trailing return after the ifs
Ralph
And how should i call it
Ralph
I mean i want the return if the expression is true
Vlad
Or else it might fall through
Ralph
What do you mean
Igor🇺🇦
What do you mean
If all " if" are false you'll not return anything.
Vlad
What do you mean
Compiler cannot analyze that those conditions would be always met
Ralph
Oh
Vlad
It simply assumes that they wont
Ralph
Yeah i see. That's why when i return a value outside of the if's it works?
Vlad
Didn't get anything
Ralph
I've added a return 1; after all the if functions. The build succeeded, and it returned 1
Vlad
You could return smth like -1
Ralph
Yeah and it worked
Vlad
To indicate out of bounds or smth
Ralph
Yeah i see