当前位置:编程学习 > C/C++ >>

水文分析与计算——年均流量及年极值洪量

[cpp] 
//年均流量及年极值洪量.h 
void NianJunZhi() 

    using namespace std; 
    ofstream outfile; 
    outfile.open("outfile_YearQ_W.txt"); 
    outfile<<setw(10)<<"年份"<<setw(10)<<"天数"<<setw(10)<<"年均流量"; 
    for(int k = 0; k < J; k++)    
        outfile<<setw(7)<<"最大"<<NumJ[k]<<"日"; 
    outfile<<endl; 
    ifstream infile; 
    infile.open("infile_DayQ.txt"); 
    for(int i = 0; i <  Y; i++) 
    { 
        Year = StartYear + i; 
        SumDay[i] =  Sum[12];//初始化 
        if(Year == StartYear) 
            SumDay[i] -= (Sum[StartMonth -1] + StartDate - 1);  
        if(Year == EndYear) 
            SumDay[i] = Sum[EndMonth - 1]+ EndDate;  
        if(Year%400==0||(Year%4==0&&Year%100!=0)) 
        { 
            if (Year == StartYear&&StartMonth< 2) SumDay[i]++; 
            if(Year == EndYear&&EndMonth > 2) SumDay[i]++; 
            if(Year!=StartYear&&Year!=EndYear) //&&SumDay[i] == Sum[12] 
                SumDay[i]++;//闰年且含2月份加一天 
        } 
        YearQ[i] = 0;//初始化 
        for(int j = 0; j < SumDay[i]; j++)  
        { 
            infile>>Q[j]; 
            YearQ[i] += Q[j]; 
        } 
        YearQ[i] /= SumDay[i]; 
        outfile<<setw(10)<<Year<<setw(10)<<SumDay[i]<<setw(10)<<YearQ[i]; 
        for(int k = 0; k<J; k++) 
        {//求年极值洪量 
             MaxYearW[i][k] = 0;//初始化 
             for(int j = 0; j < SumDay[i] - NumJ[k] + 1; j++) 
             { 
                 temp_W = 0;//初始化 
                 for(int n = 0; n < NumJ[k]; n++) 
                     temp_W += Q[j + n]; 
                 if(temp_W > MaxYearW[i][k]) 
                     MaxYearW[i][k] = temp_W;//(m3/s*月) 
             } 
             outfile<<setw(10)<<MaxYearW[i][k]; 
        }   www.zzzyk.com
        outfile<<endl; 
    } 
    infile.close(); 
    outfile.close(); 

作者:Superwen_go
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,