[cpp]
//代表性分析.h
//滑動平均值法
const int M =4,//
NumM[M] = {3, 5, 7, 9};//NumM[i]年滑動平均法
double HPMaxYearW;
void DaiBiaoFenXi()
{
using namespace std;
ofstream outfile;
outfile.open("outfile_YearW_HP.txt");
for(int k = 0; k < J; k++)
{
outfile<<setw(10)<<"年份"<<setw(7)<<"最大"<<NumJ[k]<<"日";
for(int n = 0; n < M; n++)
outfile<<setw(3)<<NumM[n]<<"年滑動平均";
outfile<<endl;
for(int i = 0; i < Y; i++)
{
outfile<<setw(10)<<i+StartYear<<setw(10)<<MaxYearW[i][k];
for(int n = 0; n < M; n++)
{
if((i < ((NumM[n] - 1)/2)) || (i > (Y - (NumM[n] + 1)/2)))
HPMaxYearW = MaxYearW[i][k];
else
{
HPMaxYearW = 0;
for(int j = i - (NumM[n] - 1)/2; j <= (i + (NumM[n] - 1)/2); j++)
HPMaxYearW += MaxYearW[j][k];
HPMaxYearW /= NumM[n];
}
outfile<<setw(13)<<HPMaxYearW;
}
outfile<<endl;
} www.2cto.com
outfile<<endl<<endl<<endl;
}
}
作者:Superwen_go