Windows编程!!!急急急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:48:50
#include<windows.h>
#include<math.h>
#include<stdio.h>
int GetRoot(float a,float b,float c,double *root)
{
double delta,deltasqrt;
delta=b*b-4.0*a*c;
if(delta<0.0)
return 0;//无根
deltasqrt=sqrt(delta);
if(a!=0.0)
{
root[0]=(-b+deltasqrt)/(2.0*a);
root[1]=(-b-deltasqrt)/(2.0*a);
}else
if(b!=0.0) root[0]=root[1]=-c/b;
else return 0;
if(root[0]==root[1])
return 1;
else return 2;
}
char str[80];
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
float a=2.0,b=6.0,c=3.0;
double root[2];
int n=GetRoot(a,b,c,root);
if(n<1)
strcpy(str,"方程无根!");
else
sprintf(str,"方程的根:%f,%f",root[0],root[1]);
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wnd

wndclass.lpszClassName =NULL;
wndclass.lpszMenuName ="HellowWin!!!!";
这2句改成
wndclass.lpszClassName ="HellowWin!!!!";
wndclass.lpszMenuName =NULL;
不过这是你应该已经改过了,要不这个程序注册不可能成功

不能显示的问题是出在这句
hwnd=CreateWindow("HelloWin","My Window",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
仔细看看,你的第一个参数,也就是类名写错了,少了3个!号
改过来就可以了,正确的是"HellowWin!!!!"

还有
ShowWindow(hwnd,nCmdShow);
后面的显示模式参数改成SW_NORMAL最好

修改为如下代码:

#include "StdAfx.h"
#include<windows.h>
#include<math.h>
#include<stdio.h>

int GetRoot(float a,float b,float c,double *root)
{
double delta,deltasqrt;
delta=b*b-4.0*a*c;
if(delta<0.0)
return 0;//无根
deltasqrt=sqrt(delta);
if(a!=0.0)
{
root[0]=(-b+deltasqrt)/(2.0*a);
root[1]=(-b-deltasqrt)/(2