c语言二次函数绘图 二次函数的c
C语言绘制而次函数曲线~~高手请进~~~!!!
我又试了一下 还是可以运行,输入a,b,c 也可以的 。 运行后,屏幕左上角不是有三个值输入输出的显示吗
成都创新互联公司是一家专注于成都做网站、网站制作与策划设计,皮山网站建设哪家好?成都创新互联公司做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:皮山等地区。皮山做网站价格咨询:18980820575
你所说的“无法输入a b c的值”能不能说的再具体一些。
#includegraphics.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); /*画纵坐标*/
/* outtextxy(8,467,"-180");*/
setlinestyle(1,0,1);
setcolor(15);
for(i=20;i640;i+=20)line(i,460,i,0);
for(i=460;i0;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; /*画笔定位在用户坐标原点 (200,460) */
y1=460-y;
if(x1640.0||x10||x640) 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();
}
用c语言画一个2次函数图像
#include windows.h
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[]=TEXT("二次函数");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if (!RegisterClass(wndclass))
{
MessageBox(NULL, TEXT("Error"),
szAppName, MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName, TEXT("二次函数"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(msg, NULL, 0, 0))
{
TranslateMessage(msg);
DispatchMessage(msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int cxClient, cyClient;
const static int n=1000;
HDC hdc;
int i;
PAINTSTRUCT ps;
POINT apt[n];
switch (message)
{
case WM_SIZE:
cxClient=LOWORD(lParam);
cyClient=HIWORD(lParam);
return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd, ps);
MoveToEx(hdc, 0, cyClient/2, NULL);
LineTo(hdc, cxClient, cyClient/2);
MoveToEx(hdc, cxClient/2, 0, NULL);
LineTo(hdc, cxClient/2, cyClient);
for (i=0; i n;++i)
{
apt[i].x=cxClient/4+i; apt[i].y=cyClient-(cyClient/2-i)*(cyClient/2-i)/300-cyClient/2+100;
}
Polyline(hdc, apt, n);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
如何C语言画二次函数图像?
C语言是面向过程的一种语言,换句话说,他只关心如何解决问题,如何以更短的时间和更少的空间解决问题,至于答案以怎样的形式表现出来,那就不是C语言要考虑的东西了。你可以直接把答案输出到屏幕上,也可以把它输出到一个文件中。如果涉及到作图一类的问题,你可以选择Turbo C,或者JAVA。
当前文章:c语言二次函数绘图 二次函数的c
标题来源:http://cdiso.cn/article/hjjieh.html