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(); } 
  • the length for the string "2 ∙ 0 ^ 9" is calculated as 5. And the second option is what? Attach the code of the second option to the question. - AK
  • "With a different code variant (no line)" - ?? - Igor
  • The working version is also non-working, because 0. Otherwise, the answers would be in the answers, not in the question. - Qwertiy pm
  • one
    @ Qwertiy ♦? For 0, too, everything works, it outputs 1. And as I have already mentioned - the working version is checked by a testing site - Amiran Korol
  • And, exactly, do while, and not just while. Then it is in the answers, and removed from the question. - Qwertiy 7:49 pm

0