• Подсчитать сумму элементов, кратных 9. C# что не так?
    class Program
    {
    static public int a_b(int[] a, int x)
    {
    for (int i = 0; i < a.Length; ++i)
    {
    if (i % 9 == 0)
    x += i;
    }
    }
    static void Main(string[] args)
    {
    int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    int x = 0;
    a_b(a, x);
    { Console.Write("{0} ", a[x]); }
    Console.ReadLine();
    }
    }
    }

Ответы 1

  • class Program    {        static void Main(string[] args)       {            int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };                     int x = 0;            //ab(a, x);            for (int i = 0; i < a.Length; ++i)            {                           if (a[i] % 9 == 0) { x += a[i];              Console.Write(a[i] + " " + i + ""); };           }              Console.ReadLine();        }    }
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years