L
L
Lisik2019-03-16 22:50:22
C++ / C#
Lisik, 2019-03-16 22:50:22

How to correctly formulate the condition?

Hello. The essence of the question is this: there is some sequence of numbers, and you need to find local maxima, while they cannot be the initial and final values. And so, how it is correct to write in if about final value? Arrays cannot be used. I know it's a stupid question, but I just can't figure it out.

...
while (c != 0) {
    count++;
    if (count > 1 && a < b && b > c && ...)
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KTG, 2019-03-16
@Lisik

If it is possible to count the number of elements: count < sequence length - 1
If not, then calculate with a delay of 1 element, and do not count the current one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question