求大神解答,是关于求物理数据的不确定度
#include<iostream>#include<cmath>
using namespace std;
double g0(int n,int a)//调用数据g0
{double g0;switch(n*a)
{case 4:g0=1.49; break;
case 5:g0=1.75; break;
case 6:g0=1.94;break;
case 7:g0=2.10;break;
case 8:g0=2.22;break;
case 9:g0=2.32;break;
case 10:g0=2.41;break;
case 11:g0=2.48;break;
case 12:g0=2.55;break;
case 20:g0=1.45;break;
case 25:g0=1.67;break;
case 30:g0=1.82;break;
case 35:g0=1.94;break;
case 40:g0=2.03;break;
case 45:g0=2.11;break;
case 50:g0=2.18;break;
case 55:g0=2.23;break;
case 60:g0=2.28;break;
default:cout<<"增加库存信息"<<endl;
}return g0;
}
int main()
{int a,n;double x,g,u1,u2,u,m,ave;
cout<<"如果a是0.01输入1,是0.05输入5"<<endl;
cin>>a;
cout<<"仪器的误差为"<<endl;
cin>>m;
cout<<"输入数据个数n"<<endl;
cin>>n;
double *b=new double[n];
while(n)
{int i=0;cout<<"输入一个数据"<<endl;
cin>>x;
b[i]=x;
i++;n--;
}delete []b;
double sum1=0;ave=0;for(int i=0;i<=(n-1);i++) sum1+=b[i];ave=sum1/n;
double sum2=0,s=0;for(int i=0;i<=(n-1);i++) sum2+=(b[i]-ave)*(b[i]-ave);
s=sqrt(sum2/(n-1));
for(int i=0;i<=(n-1);i++)
{ g=fabs(b[i]-ave)/s;
if(g>g0(n,a))
{int i; b[i]=0;
n--;}
for(int i=0;i<=(n-1);i++) sum1+=b[i];ave=sum1/n;
for(int i=0;i<=(n-1);i++) sum2+=(b[i]-ave)*(b[i]-ave);s=sqrt(sum2/(n-1));
u1=s/sqrt((double)n);
u2=m/sqrt((double)3);
u=sqrt(u1*u1+u2*u2);
cout<<"不确定度为="<<u<<endl;
}
}
为什么输入数据后得不到结果,直接结束了