一个小程序出现miss";"befor type 为什么,大侠来看看
#include<stdio.h>#include<math.h>
#include<stdlib.h>
#define PI 3.1415926
int na,np,nr,d;
int ntotal;
int lambda=2;
int k,i,l;
float wp,wr,wa;
float x;
main()
{
float colin();
float stat();
d=3*lambda;
printf("请输入中子的数量:" );
scanf("%d",&ntotal);
do{
na=np=nr=k=0;
x=0;
int i=1;
while(i<ntotal)
{
i=i+1;
k=1;
x=1;
colin();
l=1;
do{
if(k==10) {na=na+1;break;}
else if(x>d) { np=np+1;break;}
else if(x<0){nr=nr+1;break;}
else {colin();
k=k+1;
l=0;}
}while(l!=0);
}
stat();
}while(wp<=0.01);
}
float colin()
{
float r=-lambda*log((rand()%100+1)*1.0/100);
float seta=2*PI*((rand()%100+1)*1.0/100);
x=x+r*cos(seta);
return x;
}
float stat()
{
wa=na*1.0/ntotal*1.0;
wp=np*1.0/ntotal*1.0;
wr=nr*1.0/ntotal*1.0;
if(wp>0.01)
{printf("%f\n",wp);
d=d+1;}
else
printf("%f%d",wp,d);
return 0;
}