c语言大哥们,程序可以运行,但我想把结果输出在excel中
#define PI 3.14159265358979323846main()
{int i,n,t;
float deltr,f,h,N,R,R0,c,w,q;
float a1,a2,s1,s2,b1,b2,F,p1,p2,p0,I1,I2,I0,I3,I;
FILE *fp;
deltr=0.3;
R=280.72;
f=520;
N=1.49;
h=0;
w=1;
b1=0;
if(b1==0)
{p1=(N-1)*(N-1)/((N+1)*(N+1));}
else
{b2=asin(N*sin(b1));
p1=sin(b1-b2)*sin(b1-b2)/(2*sin(b1+b2)*sin(b1+b2))+tan(b1-b2)*tan(b1-b2)/(2*tan(b1+b2)*tan(b1+b2));}
n=(int)(R/deltr);
if((fp=fopen("1.txt","w"))==NULL)
{
printf("can not open the file\n");
return;
}
F=R/f;
fprintf(fp,"F=%f \n",F);
for(i=1;i<=n;i++)
{R=i*deltr;
R0=(i-1)*deltr;
c=PI*(R*R-R0*R0);
h=deltr*R/(N*sqrt(R*R+f*f)-f);
a1=atan(h/deltr);
a2=asin(N*sin(a1));
s1=a1*180/PI;
s2=a2*180/PI;
p2=sin(a1-a2)*sin(a1-a2)/(2*sin(a1+a2)*sin(a1+a2))+tan(a1-a2)*tan(a1-a2)/(2*tan(a1+a2)*tan(a1+a2));
p0=(1-p1)*(1-p2);
I3=w*c;
I+=I3;
I1=w*(1-p1)*c;
I2=(1-p2)*I1;
I0+=I2;
fprintf(fp,"%d%f%f%f%f%f%f%f%f%f%f%f%f%f%%f \n",i,R,c,h,a1,a2,s1,s2,I3,I,p1,I1,p2,I2,p0,I0);
}
q=I0/I;
fprintf(fp,"q=%f\n",q);
fclose(fp);
}
c语言大哥们,程序可以运行,但我想把结果输出在excel中,怎么改
注,if((fp=fopen("1.txt","w"))==NULL)改成if((fp=fopen("1.xsl","w"))==NULL)我也玩过,但是在excel中,没有按一格一格的存