Home > Back-end >  C language programming, to help.
C language programming, to help.

Time:05-20

Write a recursive function int count (int n), statistics, any positive integer n digits, in the main function of the input integer m, then calls the recursive function to output results,

CodePudding user response:

 # include & lt; Stdio. H> 

Int count (int n);

Int main ()
{
Int m;

The scanf (" % d ", & amp; M);

Printf (" % d \ n ", the count (m));
return 0;
}

Int count (int n)
{
Static int bit;
If (n==0)
return 0;
Bit++;
Count (n/10);

Return bit;
}


For your reference ~


CodePudding user response:

Int count (int n)
{
Return n & lt; 10? 1: the count (n/10) + 1;
}
  • Related