1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <iostream> using namespace std; int number_of_digits(int n) { int res = 0; do { n /= 10; res++; }while(n); return res; } int main() { /* int a; cin >> a; cout << "number of digits: " << number_of_digits(a) << endl; return 0; */ }