拉伸法测杨氏模量数据处理代码![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d22595109f4bf650950f57948508edf4.png#pic_center)
代码解释:
先输入标尺读数 x+ ,那一行的六个数;(单位cm)
再输入标尺读数 x- ,那一行的六个数;(单位cm)
再输入测量值 di ,那一行的六个数;(单位mm)
再输入L0,D0,b0;
得出全部结果。
#include <bits/stdc++.h>
using namespace std;
int main()
{
double E;
double m=3.0;
double k=3.1415926;
double a[6];
// double b[6
double b[6];
cout<<"please cin 6+ 6- :"<<endl;
for(int i=0 ; i<6 ; i++)
{
cin>>a[ i ];
}
for(int i=0 ; i<6 ; i++)
{
cin>>b[ i ];
}
//-----------------------------------------------------------------------------------
cout<<"+++ "<<endl;
double c[3];
for(int i=0;i<3;i++)
{
c [ i ] = a[ i + 3 ] - a [ i ] ;
cout<< c [ i ] <<" ";
}
cout<<endl;
//-----------------------------------------------------------------------------------------------
cout<<"---- "<<endl;
double d[3];
for(int i=0;i<3;i++)
{
d [ i ] = b [ i+3 ] - b [ i ];
cout<< d[ i ]<<" ";
}
cout<<endl;
//---------------------------------------------------------------x的平均值------cm-------------
double pingjun=0;
for(int i=0;i<3;i++)
{
pingjun=pingjun+c[ i ]+d [ i ];
}
pingjun=pingjun/6.0;
cout<<"pingjun "<<pingjun;
//----------------------------------------------------------求Sxm------------------cm----------------
double temp;
for(int i=0;i<3;i++)
{
temp = (c[ i ]-pingjun)*(c[ i ]-pingjun)+ (d[ i ]-pingjun)*(d[ i ]-pingjun);
}
double S;
S=temp/5;
S=sqrt(S);
cout<<"Sxm = "<<S<<endl;
//---------------------------------------------------------求Ux----------------cm----------
double Ubx=0.01;//单位换算,换成了Cm
double Ux=S*S+Ubx*Ubx;
Ux=sqrt(Ux);
cout<<"Ux = "<<Ux<<endl;
//-------------------------------------------------------------钢丝-----dping------mm------Sd--------Ud----------
//钢丝
double di[6];
cout<<"please cin di "<<endl;
for(int i=0;i<6;i++)
{
cin>>di[i];
}
double dping=0.547;
temp=0;
for(int i=0;i<6;i++)
{
temp=temp+(di[i]-dping)*(di[i]-dping);
}
double Sd=temp/5;
Sd=sqrt (Sd);
cout<<"Sd = "<<Sd<<endl;
double UBd=0.004; //换算单位,mm
double Ud=UBd*UBd+Sd*Sd;
Ud=sqrt (Ud);
cout<<"Ud = "<<Ud<<endl;
//------------------------------------------------------------------ L0 ,D0,b0的测量 -----------------
//
double UL=0.002;
double UD=0.002;
double Ub=0.00002;
double L0 ,D0 , b0;
dping=0.547;
cout<<"cin: L0 D0 b0"<<endl;
cin>>L0>>D0>>b0;
double g=9.794;
E=8*D0*m*g*L0/k/dping/dping/b0/pingjun;
E=E*10000*10000;
cout<<"E= "<<E<<endl;
double Ue;
Ue=(UL/L0)*(UL/L0)
+(UD/D0)*(UD/D0)
+4*(Ud/dping)*(Ud/dping)
+(Ub/b0)*(Ub/b0)
+(Ux/pingjun)*(Ux/pingjun);
Ue=sqrt(Ue);
Ue=E*Ue;
cout<<"Ue= "<<Ue<<endl;
cout<<"Ue/E= " <<Ue/E<<endl;
return 0;
}