← Problem book: C
Lesson 55 of 96 · 10 XP
Sign changes
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
The first line contains the count of numbers n (n ≥ 1), the second — the n integers themselves, separated by spaces. There are no zeros among the numbers.
Print how many times neighbouring numbers in the sequence have different signs.
Example
Input:
5
1 -2 -3 4 5
Output:
2
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.