1092:求出e的值

#include 
using namespace std;

int main()
{
	//1.定义变量
	double e = 1.0f;
	double factorial = 1.0f;
	int n = 0;
	//2.输入数据
	cin >> n;

	for(int i = 1; i <= n; i++)
	{
		factorial = factorial * i;
		e += 1.0 / factorial;
	}

	printf("%.10lf",e);
	return 0;
}


附 在vs2010运行c程序时,控制台一闪而过怎么解决

你可能感兴趣的:(C++基础,c++)