因为本人不熟悉VB,现手头上有一个C的程序,希望改成用VB来写,希望各位给出答案,小弟先谢过了~
#include "math.h"
main()
{ double x,x0,y,a,f,f1,K1=1125.9,Kt=2.6,S1=395.5,n1=0.193;
  long E=192000L;
  x=450.0;                            /*赋迭代初值*/
  a=1+1/n1;
  do                                 /*牛顿迭代计算 */
   { x0=x;
     f=x0*x0/E+pow(K1,(1-a))*pow(x0,a)-Kt*Kt*S1*S1/E;
     f1=2*x0/E+pow(K1,(1-a))*a*pow(x0,(a-1));
     x=x0-f/f1;
     } while(fabs(x-x0)>=1e-7);          /*精度控制10-7*/
   y=Kt*Kt*S1*S1/E/x;                 /*计算 */
   printf("x=%5.2f,y=%8.7f\n",x,y);     /*输出 保留2位小数,输出 保留7位小数*/
}
运行结果:
x=459.27,y=0.0119913C程序二:
#include "math.h"
#include "stdio.h"
main()
{ double x,x0,y,f,f1,K1=1125.9,Kt=2.6,S,n1=0.193,a;
  long E=192000L;
int I;
for (i=1;i<=5,i++)                            /*循环输入5个△S值*/
{ a=1+1/n1;x=400.0;                        /*赋迭代初值*/
   printf("input S=:");                        
   scanf("%lf", &S);                         /*输入△S*/
  do                                      /*牛顿迭代计算 */
    { x0=x;f=x0*x0/E+2*pow(2*K1,(1-a))*pow(x0,a)-Kt*Kt*S*S/E;
     f1=2*x0/E+2*pow(2*K1,(1-a))*a*pow(x0,(a-1));
    x=x0-f/f1; } while(fabs(x-x0)>=1e-7);               /*精度控制10-7 */
      y=Kt*Kt*S*S/E/x;                    /*计算 */
  printf("x=%5.2f,y=%8.7f\n",x,y);    /*输出 保留2位小数,输出 保留7位小数*/
  } printf(“end”);
}
运行结果:
input S=699.0
x=876.51,y=0.0196264
input S=521.1
x=779.54,y=0.0122644
input S=790.7
x=918.42,y=0.0239678
input S=434.1
x=720.51,y=0.0092084
input S=239.9
x=527.91,y=0.0038383C程序三:
#include "math.h"
#include "stdio.h"
main()
{ double x,y,f,f1,N,N0,D;
  int i;
  for (i=1;i<=3;i=i+1)                       /*3次循环输入3对( , )*/
{ N=1000;                              /*赋迭代初值*/
   printf("input x,y=:");
   scanf("%lf%lf",&x,&y);                  /*输入3对( , */
  do                                    /*牛顿迭代计算N*/
   { N0=N;
     f=(935.9-y)/192000*pow(N0,(-0.095))+0.26*pow(N0,(-0.47))-x;
     f1=(-0.095)*(935.9-y)/192000*pow(N0,(-1.095))-0.47*0.26*pow(N0,(-1.47));
     N=N0-f/f1;
     } while(fabs(N-N0)>=1e-7);             /*精度控制10-7 */
       D=2/N;                            /*计算损伤D*/
       printf("N=%8.2f,D=%8.7e\n",N,D);     /*输出N保留2位小数,D保留7位*/
   }   printf("end");                       /*打印end结束循环*/运行结果:
input x,y=0.0061322  -27.47
N=7288.72  D=2.743965e-4
input x,y=0.00191915  -2.595
N=542132.89  D=3.689132e-6
input x,y=0.0119839  0.06
N=1145.97  D=1.745239e-3
end用该程序计算应力功恒等法的结果为:
input x,y=0.0046965  -24.565
N=16507.23  D=1.211591e-4
input x,y=0.0017306  -4.03
N=939818.1  D=2.128071e-6
input x,y=0.00862005  0.065
N=2719.55  D=7.354148e-4
endC程序四:
#include "math.h"
main()
{ double x,x0,y,a,f,f1,K1=1125.9,Kt=2.6,S1=395.5,n1=0.193;
  long E=192000L;
x=400.0;
  a=1+1/n1;
  do
     { x0=x;
     f=x0*x0/(2*E)+pow(K1,(1-a))*pow(x0,a)/(1+n1)-Kt*Kt*S1*S1/(2*E);
     f1=x0/E+pow(K1,(1-a))*a*pow(x0,(a-1))/(1+n1);
     x=x0-f/f1;
     } while(fabs(x-x0)>=1e-7);
   y=x/E+pow(x,1/n1)/pow(K1,1/n1);
   printf("x=%5.2f,y=%8.7f\n",x,y);
}
运行结果为:
x=424.87,y=0.086250C程序五:
#include "math.h"
#include "stdio.h"
main()
{ double x,x0,y,f,f1,K1=1125.9,Kt=2.6,S,n1=0.193,a;
  long E=192000L;
  int i;
  for (i=1;i<=5;i++)
   { a=1+1/n1;x=400.0;
     printf("input S=:");
     scanf("%lf", &S);
    do
     { x0=x;f=x0*x0/(2*E)+4*K1/(n1+1)*pow((x0/2/K1),a)-Kt*Kt*S*S/(2*E);
      f1=x0/E+4*K1/(n1+1)*a*pow(x0/2/K1,(a-1));
      x=x0-f/f1;
     } while(fabs(x-x0)>=1e-7);
      y=x/E+2*pow(x/(2*K1),1/n1);
      printf("x=%5.2f,y=%8.7f\n",x,y);
   } printf("end");
}
运行结果:
input S=699.0
x=811.75,y=0.0143471
input S=521.1
x=724.63,y=0.0093930
input S=790.7
x=849.61,y=0.0172401
input S=434.1
x=671,99,y=0.0073016
input S=239.9
x=502.56,y=0.0034612如果能写成一个大程序,那就再好不过的了~~

解决方案 »

  1.   

    很简单啊。
    程序一:Sub main() Dim x, x0, y, a, f, f1
     Const K1 = 1125.9
     Const Kt = 2.6
     Const S1 = 395.5
     Const n1 = 0.193
     Const E As Long = 192000
      x = 450# '                           '赋迭代初值
      a = 1 + 1 / n1 '
      Do  '                               '牛顿迭代计算
        x0 = x
         f = x0 * x0 / E + K1 ^ (1 - a) * x0 ^ a - Kt * Kt * S1 * S1 / E
         f1 = 2 * x0 / E + K1 ^ (1 - a) * a * x0 ^ (a - 1)
         x = x0 - f / f1
       Loop While Abs(x - x0) >= 0.0000001 '          /*精度控制10-7*/
       y = Kt * Kt * S1 * S1 / E / x '                 /*计算 */
      Debug.Print "x="; Format(x, "0.00"); "y="; Format(y, "0.0000000") '     /*输出 保留2位小数,输出 保留7位小数*/
    End Sub后面的你自己写吧
      

  2.   

    直接用ThundVB插件加在VB里就可以了。
      

  3.   

    ThundVB插件可以让C,ASM代码直接用在VB中并编译.自己放狗去搜一下.