| ||||||||||
| 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 | |||||||||
求助:为什么e必须是double类型?setprecision(10)才通过,9就不对,为什么啊?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator