Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
记念一下~~~这题很简单考基础的#include <stdio.h> int jie(int n ) { int sum = 1 , i ; for( i = 1 ; i <= n ; i++ ) sum *= i ; return sum ; } int main() { int n = 9 , i = 0 ; double sum = 1 ; printf("n e\n") ; printf("- -----------\n") ; printf("0 1\n1 2\n2 2.5\n3 2.666666667\n4 2.708333333\n") ; for( i = 1 ; i <= 4 ; i++ ) { sum += 1.0 / jie(i) ; } for( i = 5 ; i <= n ; i++ ) { sum += 1.0 / jie(i) ; printf("%d %.9lf\n",i , sum ) ; } return 0 ; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator