Home > Back-end >  Big help
Big help

Time:09-16

Write a function, the function is to use recursive method for 1 + 1/2 + 1/3... 1/n, and this function is called in the main function, the output calculation results, the function prototype for the double run (int n)

CodePudding user response:

Recursive function
 
Double run (int n)
{
If (n==1)
return 1;
The else
Return the run (n - 1) + 1.0/n;
}


The main function
 
Void main ()
{
Double a=run (5);
ShowMessage (a);
}

CodePudding user response:

Now, to help out put a fart is not, later not to help, ha ha,,,

CodePudding user response:

The new number, and post the rate of 0 for help really need not too keen,
  • Related