C++向TXT写数据的问题

//change:将fopen和fclos放在外面,而:

# include & ltiostream.h & gt

# include & ltmath.h & gt

# include & ltstdio.h & gt

void main()

{

FILE * fp

fp=fopen("1.txt "," w+");// ê?3?á1t

double r=6356.766,t0=288.15,p0=101325,rou 0 = 1.2250;

double h=0,hp,w;

双k = 0.005// 2?3

双结果[4];

结果[0]=t0,结果[1]=p0,结果[2]=rou0,结果[3]= 0;

while(h & lt;=20)

{

fprintf(fp," %6.4f %8.4f %8.4f %8.4f\n ",result[0],result[1],result[2],result[3]);

h = h+k;

结果[3]= h;

如果(h & gt= 0 & amp& amph & lt=11.0191)

{

HP = h/(1+h/r);

w = 1-HP/44.3308;

结果[0]= 288.15 * w;

结果[1]=p0*pow(w,5.2559);

结果[2]=rou0*pow(w,4.2559);

}

如果(h & gt11.0191。& amph & lt=20.0631)

{

HP = h/(1+h/r);

w = exp((14.9647-HP)/6.3416));

结果[0]= 216.650;

结果[1]= 0.11953 * P0 * w;

结果[2]= 0.15898 * rou 0 * w;

}

}

fclose(FP);

}