为什么输出的u12为0???

double rr[27]={0.00005,0.00006,0.00007,0.00008,0.00009,0.0001,0.00012,0.00014,0.00016,0.00018,0.0002,0.00022,0.00024,0.00026,0.00028,0.0003,0.00032,0.00034,0.00036,0.00038,0.0004,0.00042,0.00044,0.00046,0.00048,0.0005,0.00052};

double u12[27]={0};

for(int i=0;i<27;i++)

{
xa=2.0*waveLength/8;
//cout<<"夹带系数="<<xa[0]<<'\n';
//cin.get();

//xa[0]=85134.7625e-6;

//xa[0]=2.0*waveLength/8.0-rr*ma;

ha=9.0*densityAir*VeloAmpSound*sin(k*xa)/(PI*density*w*da);
 //cout<<"夹带系数="<<eta[0]<<'\n';
//cin.get();

la=sqrt(1.0-etaA*etaA);
 //cout<<"夹带系数="<<eta[0]<<'\n';
//cin.get();

las=la/sqrt((etaA+ha*la*la)*(etaA+ha*la*la)+la*la);
 //cout<<"夹带系数="<<eta[0]<<'\n';
//cin.get();

xb=xa+rr[i]*ma;

//xb[0]=2.0*waveLength/8.0;

hb=9.0*densityAir*VeloAmpSound*sin(k*xb)/(PI*density*w*db);
 //cout<<"夹带系数="<<eta[0]<<'\n';
//cin.get();

lb=sqrt(1.0-etaB*etaB);
 //cout<<"夹带系数="<<eta[0]<<'\n';
//cin.get();

lbs=lb/sqrt((etaB+hb*lb*lb)*(etaB+hb*lb*lb)+lb*lb);
 //cout<<"夹带系数="<<eta[0]<<'\n';
//cin.get();

u12[i]=3*VeloAmpSound*(ar*las+br*lbs)/(2*PI*rr[i]);


//cout<<rr[i]<<'\t'<<u12[i]<<'\n';
ofstream outfile;  

outfile.open("f:\\s\\data.txt");

for(i=0;i<27;i++)
{

outfile<<rr[i]<<'\t'<<u12[i]<<'\n';

}
outfile.close();

1.代码段是不完整的,开头的for循环没有结束的“}”
2.如果你最后面的for循环是在开否的for里面,那么因为你最后面的for循环,导致开头的for循环只执行了一次就结束了。结果就是,最多只有u12[0]会有结果,而数组中的其他元素都没有赋值过。
3.根据我的理解和揣测,你的意图应该是在下面这句代码(u12[i]=3*VeloAmpSound*(ar*las+br*lbs)/(2*PI*rr[i]);)后面加上循环结束的“}”。