c语言问题0
我是新手,我遇到了一个问题,希望大家指点一二啊!下面是程序代码:
#include
#include
#include
#define B 1000
#define N 1000
#define A 100
void bsample(); /*函数声明*/
void sort();
main()
{
double X[N],X0,S0=0;
int i,j,m=0,S=0; /*从U[0,1]中随机产生N个样本 */
double Boot[N],T[B],X1,S1=0,W1,W2,temp,w3,w4,LEFT,RIGHT;
loop: srand((unsigned)time(NULL));
for(i=0;i
{
X[i]=(double)rand()/RAND_MAX;
}
for(i=0;i
{
S0+=X[i];
}
X0=S0/N;
for(j=0;j
{
bsample(X,Boot);
S1=0;
for(i=0;i
{
S1+=Boot[i];
}
X1=S1/N;
T[j]=X1-X0;
}
sort(T,X0);/*
for(i=0;i
for(j=0;j
if(T[j]>T[j+1])
{ temp=T[j];
T[j]=T[j+1];
T[j+1]=temp;
}
w3=T[(int)(0.025*B)-1],w4=T[(int)(0.975*B)-1];
RIGHT=X0-w3;LEFT=X0-w4;
for(m=0;m
{m=m+1;
if((0.5>LEFT)&&(0.5
S=S+1;
goto loop;
}
printf("the success times are %d\n",S);*/
/*S+=sort();
m=m+1;
if(m<1000)
goto loop;
printf("the success times are %d\n",S);*/
}
void bsample(double X[N],double Boot[N]) /*产生重复抽样样本*/
{ int i,nn;
for(i=0;i
{
nn=(int)rand()/32767.*N; /*产生0--N区间的随机数*/
Boot[i]=X[nn];
}
}
void sort(double T[B],double X0) /*排序*/
{ int i,j;double temp ,W1,W2,LEFT,RIGHT;
for(i=0;i
for(j=0;j
if(T[j]>T[j+1])
{ temp=T[j];
T[j]=T[j+1];
T[j+1]=temp;
}
W1=T[(int)(0.025*B)-1],W2=T[(int)(0.975*B)-1];
RIGHT=X0-W1;LEFT=X0-W2;/*
if((0.5>LEFT)&&(0.5
return 1;
return 0;*/
printf("%f,%f",RIGHT,LEFT);
}
我的问题是现在程序能运行,可是把注释部分也运行的话就会提示错误,编译不成功:界面如下:
Compiling...
math.c
D:\c\rr\math.c(5) : warning C4005: 'N' : macro redefinition
d:\c\rr\zuoye1.c(0) : see previous definition of 'N'
D:\c\rr\math.c(56) : error C2297: '+=' : illegal, right operand has type 'void '
D:\c\rr\math.c(68) : warning C4244: '=' : conversion from 'double ' to 'int ', possible loss of data
D:\c\rr\math.c(86) : warning C4098: 'sort' : 'void' function returning a value
D:\c\rr\math.c(87) : warning C4098: 'sort' : 'void' function returning a value
执行 cl.exe 时出错.
math.obj - 1 error(s), 0 warning(s)
有哪位大侠帮帮忙啊!