Print? /* Start the comments in the program header (to avoid any problems encountered during the submission of blog posts, the slash used to indicate that the comments have been deleted)
* Copyright and version Declaration of the program
* All rights reserved.
* File name: txt. c
* Author: liuyongshui
* Question: f = 1-i/2! + 1/3! -.... + 1/9!
* Problem source:
* Completion date: January 1, April 10, 2013
* Version No.: V1.0
*/
# Include <stdio. h>
Int I; // global variable
Int j;
Int factorial (int num); // factorial
Int main ()
{
Double f = 0;
Int flag = 1;
For (I = 1; I <= 9; I ++)
{
F + = flag * 1.0/factorial (I );
Flag =-1 * flag;
}
Printf ("the result is: % f \ n", f );
Return 0;
}
// Function Definition
Int factorial (int num) // factorial
{
Int k = 1;
For (j = 1; j <= num; j ++)
{
K * = j;
}
Return k;
}
/* Start the comments in the program header (to avoid any problems encountered during the submission of blog posts, the slash used to indicate that the comments have been deleted)
* Copyright and version Declaration of the program
* All rights reserved.
* File name: txt. c
* Author: liuyongshui
* Question: f = 1-i/2! + 1/3! -.... + 1/9!
* Problem source:
* Completion date: January 1, April 10, 2013
* Version No.: V1.0
*/
# Include <stdio. h>
Int I; // global variable
Int j;
Int factorial (int num); // factorial
Int main ()
{
Double f = 0;
Int flag = 1;
For (I = 1; I <= 9; I ++)
{
F + = flag * 1.0/factorial (I );
Flag =-1 * flag;
}
Printf ("the result is: % f \ n", f );
Return 0;
}
// Function Definition
Int factorial (int num) // factorial
{
Int k = 1;
For (j = 1; j <= num; j ++)
{
K * = j;
}
Return k;
}