[Cpp]
// Representative analysis. h
// Moving average method
Const int M = 4 ,//
NumM [M] = {3, 5, 7, 9}; // NumM [I] annual moving average method
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) <"year" <setw (7) <"maximum" <NumJ [k] <"day ";
For (int n = 0; n <M; n ++)
Outfile <setw (3) <NumM [n] <"annual moving average ";
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;
}
}
By: Superwen_go