The task is as simple as possible, but the site runs only 6/8 checks. With another code variant (without a string) everything works on 8/8. What exactly is wrong?
Input: A single non-negative integer n (0 ≤ n ≤ 2 10 ^ 9).
Calculate the number of digits of a nonnegative integer n
static void Main(string[] args) { Console.WriteLine(Console.ReadLine().Length); Console.ReadKey(); } Working option:
static void Main(string[] args) { long x =Convert.ToInt64(Console.ReadLine()); int count = 0; do { x /= 10; count++; } while (x > 0); Console.WriteLine(count); Console.ReadKey(); }