📄 quadratic function.c
字号:
#include<graphics.h>
#define BKC 9
#define COLOR 8
main()
{int gd=DETECT,gm,p=1,i;
double a,b,c,x,y,x1,y1,t;
char ch;
initgraph(&gd,&gm,"");
while(p==1)
{
setbkcolor(BKC);
setcolor(14);
setlinestyle(0,0,1);
rectangle(0,0,639,479);
line(20,460,639,460);
line(20,0,20,460);
setlinestyle(1,0,1);
setcolor(15);
for(i=20;i<640;i+=20)line(i,460,i,0);
for(i=460;i>0;i-=20)line(20,i,640,i);
setcolor(12);
setlinestyle(SOLID_LINE,0,3);
line(300,460,300,0);
line(0,360,640,360);
setcolor(15);
gotoxy(1,1);
printf("Please Enter a:" );
scanf("%lf",&a);
printf("Please Enter b:" );
scanf("%lf",&b);
printf("Please Enter c:" );
scanf("%lf",&c);
gotoxy(300,440);
printf("y= %5.2f *x^2 + %5.2f *x + %5.2f ",a,b,c);
setlinestyle(SOLID_LINE,0,1);
moveto(200,460-(a*(0-100)*(0-100)+b*(0-100)+c+100));
for(t=0.0;;t+=0.0002)
{
x=t+200;
y=a*(t-100)*(t-100)+b*(t-100)+c+100;
x1=x;
y1=460-y;
if(x1>640.0||x1<0||x>640) break;
if(y1<=480.0 &&y<=480) lineto(x1,y1);
}
setcolor(12);
outtextxy(250,8,"Finished! Continue(Y/N)?");
p=-1;
while(p==-1)
{
ch=getch();
if(ch=='y'||ch=='Y') { cleardevice();p=1;}
else if(ch=='n'||ch=='N') p=0;
else outtextxy(220,200,"ERROR! Please Press 'Y' or 'N'_" );
}
}
closegraph();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -