| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 606 人关注过本帖
标题:不确定度的代码
只看楼主 加入收藏
风之梦
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-8-31
收藏
 问题点数:0 回复次数:3 
不确定度的代码
有没有人有求不确定度的程序代码呀,谢谢各位啦
搜索更多相关主题的帖子: 代码 
2007-11-25 19:11
风之梦
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-8-31
收藏
得分:0 
是物理实验中用到的数据处理
2007-11-25 19:12
风之梦
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-8-31
收藏
得分:0 
嘿嘿,没有人理我呀,不过没关系,我自己搞定了
#include<iostream.h>
#include<math.h>
#define maxsize 20
#define max 6
double aver(double a[],int n);
double BiaoZhunPianCha(double a[],int n,double x);
double unsure(double ,double);
double unsureRel(double a,double b);
double unsure_mechine();
void dealwith(double &average,double &comp);
int main()
{
    double x[max][3],constx,average,comp, dest;
    double sum=1,uc=0,buqdd,k,extend;
    int n,i;
    cout<<"??????????????????"<<endl;
    cin>>n;
    cout<<"??????????????????"<<endl;
    cin>>constx;
    for(i=0;i<n;i++)
    {
        cout<<"??????"<<i+1<<"??±?????????"<<endl;
        cin>>x[i][2];
    }
    cout<<"???????í????"<<endl;
    for(i=0;i<n;i++)
    {
        cout<<"???í??"<<i+1<<"??????"<<endl;
        dealwith(average,comp);
        x[i][0]=average;
        x[i][1]=comp;
        cout<<endl;
    }
    for(i=0;i<n;i++)
    {
        sum*=pow(x[i][0],x[i][2]);
    }
    dest=sum*constx;
    cout<<"???á???????ù????"<<dest<<endl;
    for(i=0;i<n;i++)
         uc+=pow(x[i][1]*x[i][2],2);
    buqdd=sqrt(uc)*dest;
    cout<<"???á????±ê×????·?¨????"<<buqdd<<endl;
    cout<<"???á????±ê×????·?¨???à??????"<<buqdd/dest<<endl;
    cout<<"?????????????????·?¨?????????ò×?"<<endl;
    cin>>k;
    extend=k*buqdd;
    cout<<"???á???????????·?¨????"<<extend<<endl;
    return 0;
}
void dealwith(double  &average,double &comp)
{
    int n=0,i,j,choice;
    double y[maxsize],unsureA,unsureB,buqdd;
    cout<<"?è????????·¨???í?????????è??????1??·??ò????0"<<endl;
    cin>>choice;
    if(choice==1)
    {   
        do
        {
        cout<<"?????????í?????????????????????????????ò?á????????????"<<endl;
        cin>>n;
        }while(n%2!=0);
        cout<<"????"<<n<<"????????"<<endl;
        for(i=0;i<n;i++)
            cin>>y[i];
        j=n/2;
        for(i=0;i<n/2;i++)
        {
            y[i]=(y[j]-y[i])/(n/2);
            j++;
        }
        n=n/2;
        cout<<"?????ó??×é????????°?????"<<endl;
        for(i=0;i<n;i++)
            cout<<y[i]<<" ";
        cout<<endl;
    }
    else
    {
        cout<<"????????????????????"<<endl;
        cin>>n;
        cout<<"??????????"<<n<<"????????"<<endl;
        for(i=0;i<n;i++)
            cin>>y[i];
    }
    average=aver(y,n);
    cout<<"???ù????"<<average<<endl;
    unsureA=BiaoZhunPianCha(y,n,average);
    cout<<"A?à???·?¨????"<<unsureA<<endl;
    unsureB=unsure_mechine();
    cout<<"B?à???·?¨????"<<unsureB<<endl;
    buqdd=unsure(unsureA,unsureB);
    cout<<"???????·?¨????"<<buqdd<<endl;
    comp=unsureRel(buqdd,average);
    cout<<"???????·?¨???à??????"<<comp<<endl;
}
double aver(double a[],int n)
{
    int i;
    double sum=0;
    for(i=0;i<n;i++)
        sum+=a[i];
    return sum/n;
}
double BiaoZhunPianCha (double a[],int n,double aver)
{
    double sum=0,y,z;
    int i;
    if(n==1)
    {
        cout<<"???§??????0"<<endl;
        return 0;
    }
    for(i=0;i<n;i++)
        sum=sum+pow((a[i]-aver),2);
    y=sqrt(sum/(n-1));
    cout<<"???§??????"<<y<<endl;
    z=y/sqrt(n);
    return z;
}
double unsureRel(double a,double b)
{
    return a/b;
}
double unsure(double unsureA,double unsureB)
{
    double y;
    y= sqrt(unsureB*unsureB+unsureA*unsureA);
    return y;
}
double unsure_mechine()
{
    int n,i;
    cout<<"???????????÷???????·?¨????·???????"<<endl;
    cin>>n;
    double x,y,sum=0;
    for(i=0;i<n;i++)
    {
        cout<<"????????"<<i+1<<"??·????????í?ó????"<<endl;
        cin>>x;
        cout<<"????????"<<i+1<<"??·?????·????ò×?"<<endl;
        cin>>y;
        sum+=pow((x/y),2);
    }
    return sqrt(sum);
}
2007-12-01 10:31
风之梦
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2007-8-31
收藏
得分:0 
怎么汉字无法显示呀?
2007-12-01 10:32
快速回复:不确定度的代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067040 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved