Длина переменной "counter" и "counter2"? - C#
Формулировка задачи:
using System;
using System.Globalization;
namespace dfgdfg
{
class Program
{
static long Perevod(long x)
{
return x < 2 ? x % 2 : (x % 2) + 10 * Perevod(x / 2);
}
static void Main(string[] args)
{
Console.WriteLine("Введите X ");
long x = int.Parse(Console.ReadLine());
Console.WriteLine("Введите Y ");
long y = int.Parse(Console.ReadLine());
// конец считывания
long X = Perevod(x);
long Y = Perevod(y);
if (x >= 0)
{
Console.WriteLine("X = " + Convert.ToString(x, 2));
int c = Convert.ToInt32(X);
int counter = 0;
while (c>0)
{
counter++;
c = c / 10;
}
Console.WriteLine("Данное число содержит цифр: " + counter);
Console.WriteLine("Y = " + Convert.ToString(y, 2));
int s = Convert.ToInt32(Y); // начало считывания
int counter2 = 0;
while (s>0)
{
counter2++;
s = s / 10;
}
Console.WriteLine("Данное число содержит цифр: " + counter2);
int sm;
sm=counter+counter2;
Console.WriteLine(sm);
}
else
{
Console.WriteLine("данные не корректны");
}
Console.ReadKey();
}
}
}Решение задачи: «Длина переменной "counter" и "counter2"?»
textual
Листинг программы
10 * Perevod(x / 2);