材料力学编程.docx
《材料力学编程.docx》由会员分享,可在线阅读,更多相关《材料力学编程.docx(26页珍藏版)》请在冰豆网上搜索。
材料力学编程
材料力学上机实验作业
姓名:
侯华成学号:
1100800431班级:
1008111
一个力作用下的任意截面的弯矩,挠度
程序编译
#include
#include
main()
{
doublea,b,l,F,x,v,M,EI;
printf("一个力作用下的任意截面的弯矩,挠度\n");
printf("Pleaseinputl/m:
");
scanf("%lf",&l);
printf("Pleaseinputa/m:
");
scanf("%lf",&a);
b=l-a;
printf("PleaseinputF/N:
");
scanf("%lf",&F);
printf("Pleaseinputx/m:
");
scanf("%lf",&x);
printf("PleaseinputEI:
");
scanf("%lf",&EI);
if((x>=a)&&(x<=l))
{
v=(-F*b*((l*pow((x-a),3)/b)-(pow(l,2)-pow(b,2))*x-pow(x,3)))/(6*l);
M=(F*a*(l-x))/l;
}
else
{
v=(-F*b*x*(pow(l,2)-pow(x,2)-pow(b,2)))/(6*l);
M=(F*b*x)/l;
}
printf("v(%.2lf)=%.2lfmm\nM(%.2lf)=%.2lfkN.m\n",x,v*1000/EI,x,M/1000);
scanf("%lf%lf%lf%lf%lf",&l,&a,&x,&F,&EI);
}
一个力偶作用下的任意截面的弯矩,挠度
编译程序
#include
#include
main()
{doublea,b,l,me,x,v,M,EI;
printf("一个力偶作用下的任意截面的弯矩,挠度\n");
printf("Pleaseinputl/m:
");
scanf("%lf",&l);
printf("Pleaseinputa/m:
");
scanf("%lf",&a);
b=l-a;
printf("Pleaseinputme/N.m:
");
scanf("%lf",&me);
printf("Pleaseinputx/m:
");
scanf("%lf",&x);
printf("PleaseinputEI:
");
scanf("%lf",&EI);
if((x>=a)&&(x<=l))
{
v=(me*(-pow(x,3)+3*l*pow((x-a),2)+(pow(l,2)-3*pow(b,2))*x))/(6*l);
M=(me*(l-x))/l;
}
else
{
v=(me*x*(pow(l,2)-3*pow(b,2)-pow(x,2)))/(6*l);
M=(-me*x)/l;
}
printf("v(%.2lf)=%.2lfmm\nM(%.2lf)=%.2lfkN.m\n",x,v*1000/EI,x,M/1000);
scanf("%lf%lf%lf%lf%lf",&l,&a,&x,&me,&EI);
}
一段分布力作用下的任意截面的
程序编译
#include
#include
main()
{
doublea,b,c,l,q,x,v,M,Fa,Fb,c1,c2,c3,d3,EI;
printf("一段分布力作用下的任意截面的弯矩,挠度\n");
printf("Pleaseinputl/m:
");
scanf("%lf",&l);
printf("Pleaseinputa/m:
");
scanf("%lf",&a);
printf("Pleaseinputc/m:
");
scanf("%lf",&c);
b=l-a-c;
printf("Pleaseinputq/N/m:
");
scanf("%lf",&q);
printf("Pleaseinputx/m:
");
scanf("%lf",&x);
printf("PleaseinputEI:
");
scanf("%lf",&EI);
Fa=(q*c*(c+2*b))/(2*l);
Fb=(q*c*(c+2*a))/(2*l);
c3=(Fa*pow((a+c),3))/(3*l)-(q*a*pow(c,3))/(6*l)-(q*pow(c,4))/(8*l)+(Fb*pow(b,2))/2-(Fb*pow(b,3))/(3*l);
c2=c3-(Fb*pow(b,2))/2-(Fa*pow((a+c),2))/2+(q*pow(c,3))/6;
c1=c2;
d3=-c3*l;
if((x>(a+c))&&(x<=l))
{
v=((Fb*pow((l-x),3))/6+c3*x+d3);
M=Fb*(l-x);
}
if((x>a)&&(x<=(a+c)))
{
v=((Fa*pow(x,3))/6-(q*pow((x-a),4))/24+c2*x);
M=((q*c*x*(c+2*b))/(2*l))-((q*pow((x-a),2))/2);
}
if((x>=0)&&(x<=a))
{
v=((Fa*pow(x,3))/6+c1*x);
M=Fa*x;
}
printf("v(%.2lf)=%.2lfmm\n",x,v*1000/EI);
printf("M(%.2lf)=%.2lfkN.m\n",x,M/1000);
scanf("%lf",&l);
}
n个力共同作用下的任意截面的弯矩,挠度
程序编译
#include
#include
#defineN1000
doubleFunctionV(inti,intn,doublel,doublex,doublea[],doubleb[],doubleF[]);
doubleFunctionM(inti,intn,doublel,doublex,doublea[],doubleb[],doubleF[]);
main()
{
inti,n;
doublev[N],M[N],a[N],b[N],F[N],sumv=0,sumM=0,l,x,EI;
printf("n个力共同作用下的任意截面的弯矩,挠度\n");
printf("Pleaseinputn:
");
scanf("%d",&n);
printf("Pleaseinputl/m:
");
scanf("%lf",&l);
printf("Pleaseinputx/m:
");
scanf("%lf",&x);
printf("PleaseinputEI:
");
scanf("%lf",&EI);
for(i=0;i{
printf("Pleaseinputa[%d]/m:
",i);
scanf("%lf",&a[i]);
b[i]=l-a[i];
printf("PleaseinputF[%d]/N:
",i);
scanf("%lf",&F[i]);
v[i]=FunctionV(i,n,l,x,a,b,F);
M[i]=FunctionM(i,n,l,x,a,b,F);
sumv=sumv+v[i];
sumM=sumM+M[i];
}
printf("v(%.2lf)=%.2lfmm\n",x,sumv*1000/EI);
printf("M(%.2lf)=%.2lfkN.m\n",x,sumM/1000);
scanf("%d",&n);
}
doubleFunctionV(inti,intn,doublel,doublex,doublea[],doubleb[],doubleF[])
{
doublev;
if((x>=0)&&(x<=a[i]))
{
v=(-F[i]*b[i]*x*(pow(l,2)-pow(x,2)-pow(b[i],2)))/(6*l);
}
else
{
v=(-F[i]*b[i]*((l*pow((x-a[i]),3)/b[i])+(pow(l,2)-pow(b[i],2))*x-pow(x,3)))/(6*l);
}
returnv;
}
doubleFunctionM(inti,intn,doublel,doublex,doublea[],doubleb[],doubleF[])
{
doubleM;
if((x>=0)&&(x<=a[i]))
{
M=(F[i]*b[i]*x)/l;
}
else
{
M=(F[i]*a[i]*(l-x))/l;
}
returnM;
}
h个力偶共同作用作用下的任意截面的弯矩,挠度
程序编译
#include
#include
#defineN1000
doubleFunctionV(inti,intn,doublel,doublex,doublea[],doubleb[],doubleme[]);
doubleFunctionM(inti,intn,doublel,doublex,doublea[],doubleb[],doubleme[]);
main()
{
inti,h;
doublel,x,EI,v[N],M[N],a[N],b[N],me[N],sumv=0,sumM=0;
printf("h个力偶共同作用下的任意截面的弯矩,挠度\n");
printf("Pleaseinputh:
");
scanf("%d",&h);
printf("Pleaseinputl/m:
");
scanf("%lf",&l);
printf("Pleaseinputx/m:
");
scanf("%lf",&x);
printf("PleaseinputEI:
");
scanf("%lf",&EI);
for(i=0;i{
printf("Pleaseinputa[%d]/m:
",i);
scanf("%lf",&a[i]);
b[i]=l-a[i];
printf("Pleaseinputme[%d]/N.m:
",i);
scanf("%lf",&me[i]);
v[i]=FunctionV(i,h,l,x,a,b,me);
M[i]=FunctionM(i,h,l,x,a,b,me);
sumv=sumv+v[i];
sumM=sumM+M[i];
}
printf("v(%.2lf)=%.2lfmm\n",x,sumv*1000/EI);
printf("M(%.2lf)=%.2lfkN.m\n",x,sumM/1000);
scanf("%d",&h);
}
doubleFunctionV(inti,inth,doublel,doublex,doublea[],doubleb[],doubleme[])
{
doublev;
if((x>=0)&&(x<=a[i]))
{
v=(me[i]*x*(pow(l,2)-3*pow(b[i],2)-pow(x,2)))/(6*l);
}
else
{
v=(me[i]*(-pow(x,3)+3*l*pow((x-a[i]),2)+(pow(l,2)-3*pow(b[i],2))*x))/(6*l);
}
returnv;
}
doubleFunctionM(inti,inth,doublel,doublex,doublea[],doubleb[],doubleme[])
{
doubleM;
if((x>=0)&&(x<=a[i]))
{
M=(-me[i]*x)/l;
}
else
{
M=(me[i]*(l-x))/l;
}
returnM;
}
m段分布力共同作用下的任意截面的弯矩,挠度
#include
#include
#defineN1000
doubleFunctionV(inti,intm,doublel,doublex,doublea[],doubleb[],doublec[],doubleq[],doubleFa[],doubleFb[],doublec1[],doublec2[],doublec3[],doubled3[]);
doubleFunctionM(inti,intm,doublel,doublex,doublea[],doubleb[],doublec[],doubleq[],doubleFa[],doubleFb[],doublec1[],doublec2[],doublec3[],doubled3[]);
main()
{
inti,m;
doublel,x,EI,v[N],M[N],a[N],b[N],c[N],q[N],Fa[N],Fb[N],c1[N],c2[N],c3[N],d3[N],sumv=0,sumM=0;
printf("m段分布力共同作用下的任意截面的弯矩,挠度\n");
printf("Pleaseinputm:
");
scanf("%d",&m);
printf("Pleaseinputl/m:
");
scanf("%lf",&l);
printf("Pleaseinputx/m:
");
scanf("%lf",&x);
printf("PleaseinputEI:
");
scanf("%lf",&EI);
for(i=0;i{
printf("Pleaseinputa[%d]/m:
",i);
scanf("%lf",&a[i]);
printf("Pleaseinputc[%d]/m:
",i);
scanf("%lf",&c[i]);
b[i]=l-a[i]-c[i];
printf("Pleaseinputq[%d]/N/m:
",i);
scanf("%lf",&q[i]);
Fa[i]=(q[i]*c[i]*(c[i]+2*b[i]))/(2*l);
Fb[i]=(q[i]*c[i]*(c[i]+2*a[i]))/(2*l);
c3[i]=(Fa[i]*pow((a[i]+c[i]),3))/(3*l)-(q[i]*a[i]*pow(c[i],3))/(6*l)-(q[i]*pow(c[i],4))/(8*l)+(Fb[i]*pow(b[i],2))/2-(Fb[i]*pow(b[i],3))/(3*l);
c2[i]=c3[i]-(Fb[i]*pow(b[i],2))/2-(Fa[i]*pow((a[i]+c[i]),2))/2+(q[i]*pow(c[i],3))/6;
c1[i]=c2[i];
d3[i]=-c3[i]*l;
v[i]=FunctionV(i,m,l,x,a,b,c,q,Fa,Fb,c1,c2,c3,d3);
M[i]=FunctionM(i,m,l,x,a,b,c,q,Fa,Fb,c1,c2,c3,d3);
sumv=sumv+v[i];
sumM=sumM+M[i];
}
printf("v(%.2lf)=%.2lfmm\n",x,sumv*1000/EI);
printf("M(%.2lf)=%.2lfkN.m\n",x,sumM/1000);
scanf("%d",&m);
}
doubleFunctionV(inti,intm,doublel,doublex,doublea[],doubleb[],doublec[],doubleq[],doubleFa[],doubleFb[],doublec1[],doublec2[],doublec3[],doubled3[])
{
doublev;
if((x>=0)&&(x<=a[i]))
{
v=((Fa[i]*pow(x,3))/6+c1[i]*x);
}
if((x>a[i])&&(x<=(a[i]+c[i])))
{
v=((Fa[i]*pow(x,3))/6-(q[i]*pow((x-a[i]),4))/24+c2[i]*x);
}
if((x>(a[i]+c[i]))&&(x<=l))
{
v=((Fb[i]*pow((l-x),3))/6+c3[i]*x+d3[i]);
}
returnv;
}
doubleFunctionM(inti,intm,doublel,doublex,doublea[],doubleb[],doublec[],doubleq[],doubleFa[],doubleFb[],doublec1[],doublec2[],doublec3[],doubled3[])
{
doubleM;
if((x>=0)&&(x<=a[i]))
{
M=Fa[i]*x;
}
if((x>a[i])&&(x<=(a[i]+c[i])))
{
M=((q[i]*c[i]*x*(c[i]+2*b[i]))/(2*l))-((q[i]*pow((x-a[i]),2))/2);
}
if((x>(a[i]+c[i]))&&(x<=l))
{
M=Fb[i]*(l-x);
}
returnM;
}
n个力,h个力偶,m段分布力共同作用下的任意截面的弯矩,挠度
#include
#include
#defineN1000
doubleFunctionV1(inti,intn,doublel,doublex,doublea[],doubleb[],doubleF[]);
doubleFunctionM1(inti,intn,doublel,doublex,doublea[],doubleb[],doubleF[]);
doubleFunctionV2(inti,intn,doublel,doublex,doublea[],doubleb[],doubleme[]);
doubleFunctionM2(inti,intn,doublel,doublex,doublea[],doubleb[],doubleme[]);
doubleFunctionV3(inti,intm,doublel,doublex,doublea[],doubleb[],doublec[],doubleq[],doubleFa[],doubleFb[],doublec1[],doublec2[],doublec3[],doubled3[]);
doubleFunctionM3(inti,intm,doublel,doublex,doublea[],doubleb[],doublec[],doubleq[],doubleFa[],doubleFb[],doublec1[],doublec2[],doublec3[],doubled3[]);
main()
{
inti,n,h,m;
doublel,x,EI,a[N],b[N],v[N],M[N],sumv=0,sumM=0;
doubleF[N],sumv1=0,sumM1=0;
doubleme[N],sumv2=0,sumM2=0;
doublec[N],q[N],Fa[N],Fb[N],c1[N],c2[N],c3[N],d3[N],sumv3=0,sumM3=0;
printf("请输入:
n,h,m,l/m,x/m,EI:
");
scanf("%d%d%d%lf%lf%lf",&n,&h,&m,&l,&x,&EI);
printf("n=%d,h=%d,m=%d,l=%lfm,x=%lfm,EI%lf\n",n,h,m,l,x,EI);
printf("计算%d个力共同作用下的任意截面的弯矩,挠度\n",n);
for(i=0;i{
printf("Pleaseinputa[%d]/m:
",i);
scanf("%lf",&a[i]);
b[i]=l-a[i];
printf("PleaseinputF[%d]/N:
",i);
scanf("%lf",&F[i]);
v[i]=FunctionV1(i,n,l,x,a,b,F);
M[i]=FunctionM1(i,n,l,x,a,b,F);
sumv1=sumv1+v[i];
sumM1=sumM1+M[i];
}
printf("力共同作用结果为:
v(%.2lf)=%.2lfmmM(%.2lf)=%.2lfkN.m\n",x,sumv1*1000/EI,x,sumM1/1000);
printf("计算%d个力偶共同作用下的任意截面的弯矩,挠度\n",h);
for(i=0;i{
printf("Pleaseinputa[%d]/m:
",i);
scanf("%lf",&a[i]);
b[i]=l-a[i];
printf("Pleaseinputme[%d]/N.m:
",i);
scanf("%lf",&me[i]);
v[i]=FunctionV2(i,h,l,x,a,b,me);
M[i]=FunctionM2(i,h,l,x,a,b,me);
sumv2=sumv2+v[i];
sumM2=sumM2+M[i];
}
printf("力偶共同作用结果为:
v(%.2lf)=%.2lfmmM(%.2lf)=%.2lfkN.m\n",x,sumv2*1000/EI,x,sumM2/1000);
printf("计算%d段分布力共同作用下的任意截面的弯矩,挠度\n",m);
for(i=0;i{
printf("