fork download
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. // الأراي اللي فيها الخرفان
  8. bool?[] sheeps = {
  9. true, true, true, false,
  10. true, true, true, true,
  11. true, false, true, false,
  12. true, false, false, true,
  13. true, true, true, true,
  14. false, false, true, true
  15. };
  16.  
  17. // استدعاء الدالة وعرض النتيجة
  18. Console.WriteLine(CountSheeps(sheeps)); // الناتج: 17
  19. }
  20.  
  21. // دالة تعد الخرفان
  22. public static int CountSheeps(bool?[] sheeps)
  23. {
  24. int count = 0;
  25. foreach (bool? sheep in sheeps)
  26. {
  27. if (sheep == true)
  28. count++;
  29. }
  30. return count;
  31. }
  32. }
Success #stdin #stdout 0.07s 28776KB
stdin
using System;

class Program
{
    static void Main()
    {
        // الأراي اللي فيها الخرفان
        bool?[] sheeps = {
            true, true, true, false,
            true, true, true, true,
            true, false, true, false,
            true, false, false, true,
            true, true, true, true,
            false, false, true, true
        };

        // استدعاء الدالة وعرض النتيجة
        Console.WriteLine(CountSheeps(sheeps)); // الناتج: 17
    }

    // دالة تعد الخرفان
    public static int CountSheeps(bool?[] sheeps)
    {
        int count = 0;
        foreach (bool? sheep in sheeps)
        {
            if (sheep == true)
                count++;
        }
        return count;
    }
}
stdout
17