fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6. public static void Main()
  7. {
  8. int[] arr = Enumerable.Repeat(new Random(), 20).Select(r => r.Next(-99, 100)).ToArray();
  9. Console.WriteLine(String.Join(", ", arr));
  10. int[] signs = new int[3];
  11. Array.ForEach(arr, x => signs[Math.Sign(x) + 1]++);
  12. Console.WriteLine($"Положительных: {signs[2]}, отрицательных: {signs[0]} и нулевых: {signs[1]}");
  13. }
  14. }
Success #stdin #stdout 0.02s 16004KB
stdin
Standard input is empty
stdout
13, 34, -20, -32, 36, 77, 65, 43, -53, -83, -6, -45, 56, 64, -11, -98, -94, 2, 42, -41
Положительных: 10, отрицательных: 10 и нулевых: 0