采用逐段比较法直线插补曲线 y=1/4*x2,x∈[-5,5]
来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/05/17 19:47:39
采用逐段比较法直线插补曲线 y=1/4*x2,x∈[-5,5]
麻烦把程序编辑出来行么~
麻烦把程序编辑出来行么~
TurboC 逐段比较直线插补曲线
#include
#include
#include
#include
#include
#define SIZE 3000
float fun(float x);
float xchange(float x);
float ychange(float y);
void drawline(int color);
void drawchaline(int n, int color);
int chazhi(int *n, float deta);
const int left = 50;
const int right = 550;
const int top = 50;
const int bottom = 400;
float x[SIZE];
float x1[SIZE];
float fun(float x)
{
return x * x / 4;
}
int main()
{
int GraphDriver;
int GraphMode;
int i;
int n = 2;
float deta = 0.0001;
char buffer[10] = {'\0'};
char szfilename[255]= {"c:\\text1.txt"};
int ok;
FILE *fp;
GraphDriver = DETECT;
initgraph(&GraphDriver, &GraphMode, "");
x[0] = -5;
x[1] = 5;
setcolor(12);
outtextxy(10, 20, "Times:");
for (i = 0; i < 20; i++)
{
setcolor(0);
outtextxy(60, 20, buffer);
sprintf(buffer, "%d ", i + 1);
setcolor(12);
outtextxy(60, 20, buffer);
drawchaline(n, 0);
ok = chazhi(&n, deta);
drawchaline(n, 14);
drawline(12);
getch();
if (ok == 1)
break;
}
if ((fp = fopen(szfilename, "wt")) != NULL)
{
for (i = 0; i < n; i++)
{
fprintf(fp, "%f, %f\n", x[i], fun(x[i]));
}
fclose(fp);
}
closegraph();
return 0;
}
float xchange(float x)
{
const float fdiv = (-left + right) / 10.0f;
return (x + 5) * fdiv + left;
}
float ychange(float y)
{
const float fdiv = (top - bottom) / 6.25f;
return top + (y - 6.25) * fdiv;
}
void drawchaline(int n, int color)
{
int i;
setcolor(color);
moveto(xchange(x[0]), ychange(fun(-5)));
for (i = 1; i < n; i++)
{
lineto(xchange(x[i]), ychange(fun(x[i])));
}
}
/*min: x:-1.6,y:-17.8*/
void drawline(int color)
{
float x;
setcolor(color);
moveto(xchange(-5), ychange(fun(-5)));
for (x = -5; x deta)
{
return 0;
}
}
return 1;
}
#include
#include
#include
#include
#include
#define SIZE 3000
float fun(float x);
float xchange(float x);
float ychange(float y);
void drawline(int color);
void drawchaline(int n, int color);
int chazhi(int *n, float deta);
const int left = 50;
const int right = 550;
const int top = 50;
const int bottom = 400;
float x[SIZE];
float x1[SIZE];
float fun(float x)
{
return x * x / 4;
}
int main()
{
int GraphDriver;
int GraphMode;
int i;
int n = 2;
float deta = 0.0001;
char buffer[10] = {'\0'};
char szfilename[255]= {"c:\\text1.txt"};
int ok;
FILE *fp;
GraphDriver = DETECT;
initgraph(&GraphDriver, &GraphMode, "");
x[0] = -5;
x[1] = 5;
setcolor(12);
outtextxy(10, 20, "Times:");
for (i = 0; i < 20; i++)
{
setcolor(0);
outtextxy(60, 20, buffer);
sprintf(buffer, "%d ", i + 1);
setcolor(12);
outtextxy(60, 20, buffer);
drawchaline(n, 0);
ok = chazhi(&n, deta);
drawchaline(n, 14);
drawline(12);
getch();
if (ok == 1)
break;
}
if ((fp = fopen(szfilename, "wt")) != NULL)
{
for (i = 0; i < n; i++)
{
fprintf(fp, "%f, %f\n", x[i], fun(x[i]));
}
fclose(fp);
}
closegraph();
return 0;
}
float xchange(float x)
{
const float fdiv = (-left + right) / 10.0f;
return (x + 5) * fdiv + left;
}
float ychange(float y)
{
const float fdiv = (top - bottom) / 6.25f;
return top + (y - 6.25) * fdiv;
}
void drawchaline(int n, int color)
{
int i;
setcolor(color);
moveto(xchange(x[0]), ychange(fun(-5)));
for (i = 1; i < n; i++)
{
lineto(xchange(x[i]), ychange(fun(x[i])));
}
}
/*min: x:-1.6,y:-17.8*/
void drawline(int color)
{
float x;
setcolor(color);
moveto(xchange(-5), ychange(fun(-5)));
for (x = -5; x deta)
{
return 0;
}
}
return 1;
}
采用逐段比较法直线插补曲线 y=5*x2+16*x-5,x∈[-5,5]
急求C语言编程题:采用逐段比较法直线插补曲线 y=1/4*x2,x∈[-5,5],会的帮下忙啊,
麻烦网友们帮个忙:第1象限直线OZ,起点在原点终点的坐标为Xe =5;Ye=7;用逐点比较法补插直线?
在曲线y=x2上过哪一点的切线,(1)平行于直线y=4x-5;(2)垂直于直线2x-6y+5=0;(3)于x轴成135度
解一数学难题求垂直于直线2x-6y+1=0并且与曲线y=x3+3x2-5相切的直线方程.(注:曲线是:y=x的立方加3x
求垂直于直线2x-6y+1=0并且与曲线y=x3+5x2-5相切的直线方程.
求平行于直线3x+y+1=0并且与曲线y=x3+3x2-5相切的直线方程
垂直于直线2x-6y+1=0并且与曲线y=x3+3x2-5相切的直线方程是 ______
求垂直于直线2x-6y+1=0并且与曲线y=x3+3x2-5相切的直线方程.
求曲线y=X2(2为平方)关于直线y=x+1的对称曲线方程
曲线y=x2+2与直线5x-y-4=0所围成的图形的面积为
由曲线Y=2X2,直线Y=-4X-2,直线Y=1围成的图形面积为多少