Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求助:为什么e必须是double类型?setprecision(10)才通过,9就不对,为什么啊?

Posted by rainstorm at 2007-08-19 22:32:46 on Problem 1517
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	int i;
	double e = 0.0;
    cout << "n " << 'e' << endl;
	cout << "- -----------" << endl;
	int Factorial(int n);
	for(i = 0; i < 10; i++)
	{
		e += 1.0 / Factorial(i);	
		cout << i << ' ' << setprecision(10) << e << endl;
	}
	return 0;
}

int Factorial(int n)
{
	int multipul = 1;
	for(int j = 1; j <= n; j++)
	{
		multipul = multipul * j;
	}
	return multipul;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator