/* © MATTO MATTI 2018 http://mattomatti.com/pl/a0138 napisane przy użyciu Visual Studio Community 2015 2018-08-08 v 1.0 */ using System; namespace plcode1cs { class Program { static int policzKroki(int[] tab) { int ileZer = 0, krokow = 0; for (int i = 0; i < tab.Length; i++) { if (tab[i] % 2 == 1) { tab[i]--; krokow++; } tab[i] /= 2; if (tab[i] == 0) ileZer++; } if (ileZer < tab.Length) { krokow++; krokow += policzKroki(tab); } return krokow; } static void Main(string[] args) { Console.WriteLine("Podaj listę elementów:"); string[] dane = Console.ReadLine().Split(' '); int[] tab = new int[dane.Length]; for (int i = 0; i < dane.Length; i++) tab[i] = Convert.ToInt32(dane[i]); Console.WriteLine(policzKroki(tab)); Console.ReadKey(); } } }