求助:如何将如下C语言程序转换为其他语言?
第一段程序#include<stdio.h>
#include<math.h>
main()
{int i,j,n;
float x[100],h,a=0,b=0.25,I=0,f[100]={0};
system("cls");
printf(" The integrand:sqrt(4-pow(sin(x),2);\n");
printf(" The upper and lower of the integral:b=1/4 a=0\n ");
printf("\n\n");
printf(" Enter the number of the segment n: ");
scanf("%d",&n);
printf("\n\n");
h=(b-a)/n;
for(i=1;i<n;i++)
x[i]=a+i*h;
for(i=1;i<n;i++)
f[i]=sqrt(4-pow(sin(x[i]),2));
for(i=1;i<n;i++)
I=I+f[i];
I=I*h+h*(sqrt(4-pow(sin(a),2))+sqrt(4-pow(sin(a),2)))/2;
printf("I=%f\n",I);
}
第二段程序
#include<stdio.h>
#include<math.h>
#define e 2.718281828
main()
{int i,j,n;
float x[100],xx[100],h,a=0,b=1,I1=0,I2=0,f[100]={0},y
[100],S;
system("cls");
printf(" The integrand:pow(e,x)/(4+pow(x,2);\n");
printf(" The upper and lower of the integral:b=1 a=0\n ");
printf("\n\n");
printf(" Enter the number of the segment n: ");
printf("\n\n");
h=(b-a)/n;
for(i=1;i<n;i++)
x[i]=a+i*h;
for(i=2;i<n;i++)
xx[i]=(x[i]+x[i-1])/2;
xx[1]=(a+x[1])/2;
xx[n]=(x[n-1]+b)/2;
for(i=1;i<n;i++)
f[i]=pow(e,x[i])/(4+pow(x[i],2));
for(i=1;i<=n;i++)
y[i]=pow(e,xx[i])/(4+pow(xx[i],2));
for(i=1;i<n;i++)
I1=I1+f[i];
for(i=1;i<=n;i++)
I2=I2+y[i];
S=(I1+2*I2)*h/3+h*(pow(e,a)/(4+pow(a,2))+pow(e,b)/(4+pow
(b,2)))/6;
printf("S=%f\n",S);
}
第三段程序
#include <math.h>
#include <stdio.h>
main()
{int m,i,c,j,r,u;
int n;
double a=0,b=1.0,f,t,x,h,T=1.0;
double aa[10][10]={0},v[1000]={0};
system("cls");
printf(" The integrand:sin(x)/x;\n");
printf(" The upper and lower of the integral:b=1.0 a=0\n ");
aa[0][0]=1.0*(b-a)*(1+sin(b)/b)/2;
printf("%f\n",aa[0][0]);
for(i=1;fabs(T)>=1e-2;i++)
{ n=pow(2,i);
h=(b-a)*1.0/n;
for(m=1,c=0;m<n;c++)
{ v[c]=a+m*h;
m=m+2;
}
for(t=0;t<c;t++)
aa[i][0]=aa[i][0]+1.0*h*sin(v[t])/v[t];
aa[i][0]=aa[i][0]+0.5*aa[i-1][0];
for(j=1;j<=i;j++)
aa[i][j]=(pow(4,j)*aa[i][j-1]-1.0*aa[i-1][j-1])/(pow(4,j)-1);
T=aa[i][i]-aa[i-1][i-1];
}
printf(" c=%d n=%d\n",c,n);
printf("\n");
for(u=0;u<i;u++)
{ for(r=0;r<=u;r++)
{printf(" %.7f", aa[u][r]);}
printf("\n");}
}