符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
#include windows.h
创新互联公司主要从事网站设计制作、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务海淀,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
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的标准库中有graphic.h头文件,实现了很多画图函数 比如 lineto, moveto, arc,(函数名可能记错,好久没用了-.-!)
直线:起点加终点就行。
二次曲线,比如抛物线,那就以定长拆分成小直线。双曲线同理。
抛物线,和双曲线用定长拆分,估计很难计算。要是精度要求不高就根据情况改成定x,或者定y偏移的拆分,要是精度要求高那就去找直线拟合曲线的算法或者双圆弧拟合曲线的算法。
首先你已经很清楚的说明了你这个程序是用C语言写二次函数的,而当a=0时,就不是二次函数了,应该按照一次函数来进行计算,否则 一个数除以0就没有意义了.~
#include stdio.h
#include stdlib.h
#include math.h
int main()
{
float a,b,c;
float x1,x2,m;
printf("input number a=:");
scanf("%f",a);
printf("input number b=:");
scanf("%f",b);
printf("input number c=:");
scanf("%f",c);
if(a==0)
printf("一根:%f\n",c*(-1)/b);
else if(a==0b==0)
printf("无意义!");
else
{
m=b*b-4*a*c;
if(m0)
{
printf("两根\n");
printf("x1=%f\n",(-b+sqrt(m))/(2*a));
printf("x2=%f\n",(-b-sqrt(m))/(2*a));
}
else if(m==0)
printf("x1=x2=%f\n",x1);
}
else
printf("无实根\n");
}
return 0;
}
#include stdio.h
#include stdlib.h
#include math.h
int main()
{
float a,b,c;
float x1,x2,m;
printf("input number a=:");
scanf("%f",a);
printf("input number b=:");
scanf("%f",b);
printf("input number c=:");
scanf("%f",c);
m=b*b-4*a*c;
if(m=0a!=0){
if(m0){
x1=(-b+sqrt(m))/(2*a);
x2=(-b-sqrt(m))/(2*a);
printf("两根\n");
printf("x1=%f\n",x1);
printf("x2=%f\n",x2);}
else
printf("一根\n");
printf("x1=x2=%f\n",x1);}
else
{
if(a=0 b!=0) printf("根是x=-c/b");
if(a=0b=0) printf("为常函数");
if(a!=0) printf("无根\n");
}
system("PAUSE");
return 0; }