该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
#include
#include"resource.h" BOOL CALLBACK DlgMain(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,DlgMain);
return 0;
} BOOL CALLBACK DlgMain(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
{
EndDialog(hwnd,0);
return TRUE;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDOK:
{
int a= GetDlgItemInt(hwnd,IDC_EDIT1,NULL,FALSE);
int b= GetDlgItemInt(hwnd,IDC_EDIT2,NULL,FALSE);
int c= GetDlgItemInt(hwnd,IDC_EDIT3,NULL,FALSE);
double d;
double x1,x2;
char umsg[100],t[100];
d=b*b-4*a*c;
x1=(-b+sqrt(d))/2;
x2=(-b-sqrt(d))/2;
if(d<0)
MessageBox (NULL,TEXT("方程无解"),TEXT("结果"),0);
if(d==0)
{
sprintf(umsg,_T("有两个相同的实根%.2lf"),x1);
MessageBox(NULL,TEXT(umsg), TEXT("结果"),0);
}
if(d>0)
{
sprintf(umsg,_T("有两不相同的实根%.2lf和%.2lf"),x1,x2);
MessageBox(NULL,TEXT(umsg), TEXT("结果"),0);
}
}
}
}
}
return FALSE;
}