Advertisement
Pearlfromsu

Untitled

Sep 30th, 2021
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. using System;
  2. class HelloWorld
  3. {
  4. static void Main()
  5. {
  6. int cnt = 0, n = int.Parse(Console.ReadLine());
  7. double prev = int.Parse(Console.ReadLine());
  8. for (int i = 1; i < n; i++) {
  9. double now = int.Parse(Console.ReadLine());
  10. if ((now < 0) != (prev < 0) && (now != 0 && prev != 0))
  11. cnt++;
  12. prev = now;
  13. }
  14. Console.WriteLine("Число соседств двух чисел разного знака: " + cnt);
  15. Console.ReadKey();
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement