?? cpptemplate.cpp
字號:
//=====================================
// title: 數組排序
// author: cjj
// date: 2007-10-09
/* Description:
*/
//=====================================
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int Factorial(int n);
double Stirling(int n); //斯特林近似法(stirling'sapproximation)
const double PI=3.1415926;
const double E=2.718;
int main()
{
for(int n; cin>>n;)
{
cout<<fixed<<setprecision(2)<<setw(6)<<Stirling(n)<<endl;
cout<<setw(6)<<Factorial(n)<<endl;
}
return 0;
}
double Stirling(int n)
{
return sqrt(2*PI*n)*pow(n/E,n);
}
int Factorial(int n)
{
int result=1;
if(n==0) return 1;
for(int i=1; i<=n; i++)
{
result*=i;
}
return result;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -