水文分析与计算——代表性分析(滑动平均法)

时间:2021-12-12 04:10:05
//代表性分析.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;
}
outfile<<endl<<endl<<endl;
}
}