โจทย์
ดูฉบับแปลCount how many decimal digits n has when written normally, without leading zeros.
Implement count_digits(n).
Input
n: A positive integer.
Output
Return the number of digits.
เงื่อนไข
1 ≤ n ≤ 10¹⁸
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
n = 352
ผลลัพธ์ที่คาดหวัง:
expected = 3
อินพุต:
long long n = 352;
ผลลัพธ์ที่คาดหวัง:
long long expected = 3;
อินพุต:
long n = 352;
ผลลัพธ์ที่คาดหวัง:
long expected = 3;
คำอธิบาย
352 has three digits.
ตัวอย่างที่ 2
อินพุต:
n = 7
ผลลัพธ์ที่คาดหวัง:
expected = 1
อินพุต:
long long n = 7;
ผลลัพธ์ที่คาดหวัง:
long long expected = 1;
อินพุต:
long n = 7;
ผลลัพธ์ที่คาดหวัง:
long expected = 1;
คำอธิบาย
A single digit.