回 帖 发 新 帖 刷新版面

主题:求大神指点啊!!!

#include<stdio.h>
#include<math.h>
void main()
{
    float D1=1.1,D2=1.5,D3=1.8,D4=0.8,D5=0.8,L1=111.61,L2=289.95,L3=5029.12,L4=22.96,L5=29.93,a1=1110,a2=1048,a3=1031,a4=1113,a5=1113,F1=0.0268,F2=0.0233,F3=0.0202,F4=0.0226,F5=0.0237,
          Hor1=373.53,Hor2=374.6,Vo1=2.55,Vo2=2.93,Q=7.6,g=9.81,t=0.02,T1=0.01,T2=0.2;
    float Vo3,Vo4,Vo5,A1,A2,A3,A4,A5,C11,C21,C31,C12,C22,C32,C13,C23,C33,C14,C24,C34,C15,C25,C35,C41,C42,C43,C44,C45,C51,C52,C53,C54,C55,C64,C65,C74,C75,W1,W2,W3,W4,W5,W6,
          J,x1,x2,x3,x4,x5,O1,O2,O3,O4,O5;
    int   m1=5,m2=14,m3=244,m4=1,m5=1,n,i,k;
    float V1[6][10],V2[15][10],V3[245][10],V4[2][10],V5[2][10],
          H1[6][10],H2[15][10],H3[245][10],H4[2][10],H5[2][10],
          Vs1[6][10],Vs2[15][10],Vs3[245][10],Vs4[2][10],Vs5[2][10],
          Vr1[6][10],Vr2[15][10],Vr3[245][10],Vr4[2][10],Vr5[2][10],
          Hs1[6][10],Hs2[15][10],Hs3[245][10],Hs4[2][10],Hs5[2][10],
          Hr1[6][10],Hr2[15][10],Hr3[245][10],Hr4[2][10],Hr5[2][10],
          P[10];
       A1=0.25*3.14*D1*D1;
       A2=0.25*3.14*D2*D2;
       A3=0.25*3.14*D3*D3;
       A4=0.25*3.14*D4*D4;
       A5=0.25*3.14*D5*D5;
        x1=L1/m1;
        x2=L2/m2;
        x3=L3/m3;
         x4=L4/m4;
        x5=L5/m5;

    O1=t/x1;
    O2=t/x2;
    O3=t/x3;
    O4=t/x4;
    O5=t/x5;

    n=(T2/t);

    C11=a1/g;
    C21=(F1*t)/(2*D1);
    C31=F1*x1/(2*g*D1);
    C12=a2/g;
    C22=(F2*t)/(2*D2);
    C32=F2*x2/(2*g*D2);
    C13=a3/g;
    C23=(F3*t)/(2*D3);
    C33=F3*x3/(2*g*D3);
    C14=a4/g;
    C24=(F4*t)/(2*D4);
    C34=F4*x4/(2*g*D4);
    C15=a5/g;
    C25=(F5*t)/(2*D5);
    C35=F5*x5/(2*g*D5);
    Vo3=Q/A3;
    Vo4=Q/(2*A4);
    Vo5=Q/(2*A5);
    printf("x1=%0.2f,x2=%0.2f,x3=%0.2f,x4=%0.2f,x5=%0.2f,C31=%f,C32=%f,C33=%f,C34=%f,C35=%f,n=%d,Vo1=%0.2f,Vo2=%0.2f,Vo3=%0.2f,Vo4=%0.2f,Vo5=%0.2f\n",x1,x2,x3,x4,x5,C31,C32,C33,C34,C35,n,Vo1,Vo2,Vo3,Vo4,Vo5);
    for(i=0;i<=m1;i++)
    {
    H1[0][i]=Hor1-i*C31*Vo1*Vo1;
    V1[0][i]=Vo1;
    }
    for(i=0;i<=m2;i++)
    {
    H2[0][i]=Hor2-i*C32*Vo2*Vo2;
    V2[0][i]=Vo2;
    }
    for(i=0;i<=m3;i++)
    {
    H3[0][i]=H1[0][m1]-i*C33*Vo3*Vo3;
    V3[0][i]=Vo3;
    }
    for(i=0;i<=m4;i++)
    {
    H4[0][i]=H3[0][m3]-i*C34*Vo4*Vo4;
    V4[0][i]=Vo4;
    }
    for(i=0;i<=m5;i++)
    {
    H5[0][i]=H3[0][m3]-i*C35*Vo5*Vo5;
    V5[0][i]=Vo5;
    }
    for(k=1;k<=n;k++)
    {
        Hs1[k-1][0]=H1[k-1][0]-O1*a1*(H1[k-1][0]-H1[k-1][1]);
        Vs1[k-1][0]=V1[k-1][0]-O1*a1*(V1[k-1][0]-V1[k-1][1]);
        Hs2[k-1][0]=H2[k-1][0]-O2*a2*(H2[k-1][0]-H2[k-1][1]);
        Vs2[k-1][0]=V2[k-1][0]-O2*a2*(V2[k-1][0]-V2[k-1][1]);
        Hs3[k-1][0]=H3[k-1][0]-O3*a3*(H3[k-1][0]-H3[k-1][1]);
        Vs3[k-1][0]=V3[k-1][0]-O3*a3*(V3[k-1][0]-V3[k-1][1]);
        Hs4[k-1][0]=H4[k-1][0]-O4*a4*(H4[k-1][0]-H4[k-1][1]);
        Vs4[k-1][0]=V4[k-1][0]-O4*a4*(V4[k-1][0]-V4[k-1][1]);
        Hs5[k-1][0]=H5[k-1][0]-O5*a5*(H5[k-1][0]-H5[k-1][1]);
        Vs5[k-1][0]=V5[k-1][0]-O5*a5*(V5[k-1][0]-V5[k-1][1]);

        Hr1[k-1][m1]=H1[k-1][m1]-O1*a1*(H1[k-1][m1]-H1[k-1][m1-1]);
        Vr1[k-1][m1]=V1[k-1][m1]-O1*a1*(V1[k-1][m1]-V1[k-1][m1-1]);
        Hr2[k-1][m2]=H2[k-1][m2]-O2*a2*(H2[k-1][m2]-H2[k-1][m2-1]);
        Vr2[k-1][m2]=V2[k-1][m2]-O2*a2*(V2[k-1][m2]-V2[k-1][m2-1]);
        Hr3[k-1][m3]=H3[k-1][m3]-O3*a3*(H3[k-1][m3]-H3[k-1][m3-1]);
        Vr3[k-1][m3]=V3[k-1][m3]-O3*a3*(V3[k-1][m3]-V3[k-1][m3-1]);
        Hr4[k-1][m4]=H4[k-1][m4]-O4*a4*(H4[k-1][m4]-H4[k-1][m4-1]);
        Vr4[k-1][m4]=V4[k-1][m4]-O4*a4*(V4[k-1][m4]-V4[k-1][m4-1]);
        Hr5[k-1][m5]=H5[k-1][m5]-O5*a5*(H5[k-1][m5]-H5[k-1][m5-1]);
        Vr5[k-1][m5]=V5[k-1][m5]-O5*a5*(V5[k-1][m5]-V5[k-1][m5-1]);

        C41=Hs1[k-1][0]-Vs1[k-1][0]*(C11-C31*fabs(Vs1[k-1][0]));
        C42=Hs2[k-1][0]-Vs2[k-1][0]*(C12-C32*fabs(Vs2[k-1][0]));
        C43=Hs3[k-1][0]-Vs3[k-1][0]*(C13-C33*fabs(Vs3[k-1][0]));
        C44=Hs4[k-1][0]-Vs4[k-1][0]*(C14-C34*fabs(Vs4[k-1][0]));
        C45=Hs5[k-1][0]-Vs5[k-1][0]*(C15-C35*fabs(Vs5[k-1][0]));

        C51=Hr1[k-1][m1]+Vr1[k-1][m1]*(C11-C31*fabs(Vr1[k-1][m1]));
        C52=Hr2[k-1][m2]+Vr2[k-1][m2]*(C12-C32*fabs(Vr2[k-1][m2]));
        C53=Hr3[k-1][m3]+Vr3[k-1][m3]*(C13-C33*fabs(Vr3[k-1][m3]));
        C54=Hr4[k-1][m4]+Vr4[k-1][m4]*(C14-C34*fabs(Vr4[k-1][m4]));
        C55=Hr5[k-1][m5]+Vr5[k-1][m5]*(C15-C35*fabs(Vr5[k-1][m5]));
    
        H1[k][0]=H1[0][0];
        H2[k][0]=H2[0][0];
         V1[k][0]=(H1[0][0]-C41)/C11;
        V2[k][0]=(H2[0][0]-C42)/C12;

        H1[k][m1]=(C51*A1/C11+C52*A2/C12+C43*A3/C13)/(A1/C11+A2/C12+A3/C13);
        H2[k][m2]=H1[k][m1];
        H3[k][0]=H1[k][m1];
        V1[k][m1]=(C51-H1[k][m1])/C11;
        V2[k][m2]=(C52-H2[k][m2])/C12;
        V3[k][0]=(-C43+H3[k][0])/C13;

        H3[k][m3]=(C53*A3/C13+C44*A4/C14+C45*A5/C15)/(A3/C13+A4/C14+A5/C15);
        H4[k][0]=H3[k][m3];
        H5[k][0]=H3[k][m3];
        V3[k][m3]=(C53-H3[k][m3])/C13;
        V4[k][0]=(-C44+H4[k][0])/C14;
        V5[k][0]=(-C45+H5[k][0])/C15;


        J=k*t; 
        if(J>=T1)
        {
        P[k]=0;
        V4[k][m4]=0;
        H4[k][m4]=C54-C14*V4[k][m4];
        V5[k][m5]=0;
        H5[k][m5]=C55-C15*V5[k][m5];
        }
        else
        {
        P[k]=(1-J/T1);
        C64=(Vo4*Vo4*P[k]*P[k])/H4[0][m4];
        C74=C64*C14/2;
        V4[k][m4]=-C74+sqrt(C74*C74+C54*C64);    
        H4[k][m4]=C54-C14*V4[k][m4];

        C65=(Vo5*Vo5*P[k]*P[k])/H5[0][m5];
        C75=C65*C15/2;
        V5[k][m5]=-C75+sqrt(C75*C75+C55*C65);    
        H5[k][m5]=C55-C15*V5[k][m5];
        }
        P[0]=1;

    
        for(i=1;i<=m1-1;i++)
        {
            Hs1[k-1][i]=H1[k-1][i]-O1*a1*(H1[k-1][i]-H1[k-1][i+1]);
            Vs1[k-1][i]=V1[k-1][i]-O1*a1*(V1[k-1][i]-V1[k-1][i+1]);
            Hr1[k-1][i]=H1[k-1][i]-O1*a1*(H1[k-1][i]-H1[k-1][i-1]);
            Vr1[k-1][i]=V1[k-1][i]-O1*a1*(V1[k-1][i]-V1[k-1][i-1]);
            W1=(Hr1[k-1][i]-Hs1[k-1][i])/C11;
            W2=Vr1[k-1][i]+Vs1[k-1][i];
            W3=Vr1[k-1][i]*fabs(Vr1[k-1][i])+Vs1[k-1][i]*fabs(Vs1[k-1][i]);
            W4=Hr1[k-1][i]+Hs1[k-1][i];
            W5=C11*(Vr1[k-1][i]-Vs1[k-1][i]);
            W6=Vr1[k-1][i]*fabs(Vr1[k-1][i])-Vs1[k-1][i]*fabs(Vs1[k-1][i]);
            V1[k][i]=0.5*(W1+W2-C21*W3);
             H1[k][i]=0.5*(W4+W5-C31*W6);
        }
        for(i=1;i<=m2-1;i++)
        {
            Hs2[k-1][i]=H2[k-1][i]-O2*a2*(H2[k-1][i]-H2[k-1][i+1]);
            Vs2[k-1][i]=V2[k-1][i]-O2*a2*(V2[k-1][i]-V2[k-1][i+1]);
            Hr2[k-1][i]=H2[k-1][i]-O2*a2*(H2[k-1][i]-H2[k-1][i-1]);
            Vr2[k-1][i]=V2[k-1][i]-O2*a2*(V2[k-1][i]-V2[k-1][i-1]);
            W1=(Hr2[k-1][i]-Hs2[k-1][i])/C12;
            W2=Vr2[k-1][i]+Vs2[k-1][i];
            W3=Vr2[k-1][i]*fabs(Vr2[k-1][i])+Vs2[k-1][i]*fabs(Vs2[k-1][i]);
            W4=Hr2[k-1][i]+Hs2[k-1][i];
            W5=C12*(Vr2[k-1][i]-Vs2[k-1][i]);
            W6=Vr2[k-1][i]*fabs(Vr2[k-1][i])-Vs2[k-1][i]*fabs(Vs2[k-1][i]);
            V2[k][i]=0.5*(W1+W2-C22*W3);
             H2[k][i]=0.5*(W4+W5-C32*W6);    
        }
        for(i=1;i<=m3-1;i++)
        {
            Hs3[k-1][i]=H3[k-1][i]-O3*a3*(H3[k-1][i]-H3[k-1][i+1]);
            Vs3[k-1][i]=V3[k-1][i]-O3*a3*(V3[k-1][i]-V3[k-1][i+1]);
            Hr3[k-1][i]=H3[k-1][i]-O3*a3*(H3[k-1][i]-H3[k-1][i-1]);
            Vr3[k-1][i]=V3[k-1][i]-O3*a3*(V3[k-1][i]-V3[k-1][i-1]);
            W1=(Hr3[k-1][i]-Hs3[k-1][i])/C13;
            W2=Vr3[k-1][i]+Vs3[k-1][i];
            W3=Vr3[k-1][i]*fabs(Vr3[k-1][i])+Vs3[k-1][i]*fabs(Vs3[k-1][i]);
            W4=Hr3[k-1][i]+Hs3[k-1][i];
            W5=C13*(Vr3[k-1][i]-Vs3[k-1][i]);
            W6=Vr3[k-1][i]*fabs(Vr3[k-1][i])-Vs3[k-1][i]*fabs(Vs3[k-1][i]);
            V3[k][i]=0.5*(W1+W2-C23*W3);
             H3[k][i]=0.5*(W4+W5-C33*W6);    
        }
        
    }
     printf("%s   %s   %s   %s   %s   %s   %s  %s\n","时间", "管1上游端","管2上游端","分岔处1","分岔处2","管4孔口","管5孔口","开度");
    for(k=0;k<=n;k++)
    {
        printf("%.3f  ",k*t);
        printf("   %4.4f      %4.4f      %4.4f     %4.4f   %4.4f     %4.4f ",H1[k][0],H2[k][0],H3[k][0],H3[k][m3],H4[k][m4],H5[k ][m5]);
        printf("%.5f",P[k]);
         printf("\n");
    }
   
}

回复列表 (共5个回复)

沙发

0x004024fd 指令引用的 0x059562b4 内存。该内存不能为 written 。   神马意思啊?

板凳

怎样改

3 楼

程序怎样简化啊/

4 楼

俺是水利水电专业的,毕业设计要搞编程,各种不懂。半学期就弄这出来,还不能运行,求大神指点!qq:546694596

5 楼

要答辩了,求大神解决啊

我来回复

您尚未登录,请登录后再回复。点此登录或注册