Я скину готовую в С++ нада сделать под паскаль)) помогите плз #include <iostream.h>
#include<math.h>
#include <iomanip>
double x,y,z,a,b,x2,x1,s,n,e,sgn,j,k,l,m,h,o,p;
double f(double q){return q*q/2-sin(q);}
main()
{
n=30;
e=0.0001;
a=0;
b=100;
j=b-a;
x=1;
y=1;
for(int i=3;i<n;i++)
{
z=y+x;
x=y;
y=z;
}
printf("Fn-2=%.0f\n",x);
printf("Fn-1=%.0f\n",z);
s=x+z;
printf("Fn=%.0f\n",s);
printf("\n");
for(int t=0;t<n;t++)
{
if(n==2*t)
{
sgn=1;
printf("sgn=%.0f\n",sgn);
}
if(n==2*t+1)
{
sgn=-1;
printf("sgn=%.0f\n",sgn);
}
}
k=(z*j+sgn*e)/s;
printf("%.10f\n",k);
x2=b-k;
x1=a+b-x2;
printf("x1=%.10f\n",x1);
printf("x2=%.10f\n",x2);
m=f(x1);
h=f(x2);
o=f(a);
p=f(b);
printf("f(x1)=%.10f\n",m);
printf("f(x2)=%.10f\n",h);
printf("f(a)=%.10f\n",o);
printf("f(b)=%.10f\n",p);
for(int w=1;w<n;w++)
{
if(x2>x1)
{
if(h>m)
{b=x2;
x2=a+b-x1;
m=f(x1);
h=f(x2);
printf("1\n");
printf("a=%.10f\n",a);
printf("b=%.10f\n",b);
printf("x1=%.10f\n",x1);
printf("x2=%.10f\n",x2);
printf("f(x1)=%.10f\n",m);
printf("f(x2)=%.10f\n\n",h);
}
else//(m>h)
{a=x1;
x1=a+b-x2;
m=f(x1);
h=f(x2);
printf("2\n");
printf("a=%.10f\n",a);
printf("b=%.10f\n",b);
printf("x1=%.10f\n",x1);
printf("x2=%.10f\n",x2);
printf("f(x1)=%.10f\n",m);
printf("f(x2)=%.10f\n\n",h);
}
}
if(x2<x1)
{
if(h<m)
{b=x1;
x1=a+b-x2;
m=f(x1);
h=f(x2);
printf("3\n");
printf("a=%.10f\n",a);
printf("b=%.10f\n",b);
printf("x1=%.10f\n",x1);
printf("x2=%.10f\n",x2);
printf("f(x1)=%.10f\n",m);
printf("f(x2)=%.10f\n\n",h);
}
else//(h>m)
{a=x2;
x2=a+b-x1;
m=f(x1);
h=f(x2);
printf("4\n");
printf("a=%.10f\n",a);
printf("b=%.10f\n",b);
printf("x1=%.10f\n",x1);
printf("x2=%.10f\n",x2);
printf("f(x1)=%.10f\n",m);
printf("f(x2)=%.10f\n\n",h);
}
}
}
return 0;
}