资源简介
汉诺塔是一个很简单的递归程序,这个代码是将递归过程演示了一下,用vc6.0开发的。。。。

代码片段和文件信息
// hanoi.cpp : Defines the entry point for the application.
//
#include “stdafx.h“
#include “resource.h“
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR sztitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE int);
LRESULT CALLBACK WndProc(HWND UINT WPARAM LPARAM);
LRESULT CALLBACK About(HWND UINT WPARAM LPARAM);
#define idc_1 201
#define idc_2 202
#define idc_3 203
struct
{
int istyle ;
TCHAR * szText ;
}
button[] =
{
BS_PUSHBUTTON TEXT (“盘子数“)
BS_PUSHBUTTON TEXT (“移动速度“)
BS_PUSHBUTTON TEXT (“提交盘子数“)
BS_AUTOCHECKBOX TEXT (“AUTOCHECKBOX“)
BS_RADIOBUTTON TEXT (“RADIOBUTTON“)
BS_3STATE TEXT (“3STATE“)
BS_AUTO3STATE TEXT (“AUTO3STATE“)
BS_GROUPBOX TEXT (“GROUPBOX“)
BS_AUTORADIOBUTTON TEXT (“AUTORADIO“)
BS_OWNERDRAW TEXT (“OWNERDRAW“)
} ;
bool flag=false;
int speed=1000;
//中外的杀人者竟然个个昂起头来,不知脸上有血污。
class dish
{
public:
int index;
int length;
dish(int xint y){index=x;length=y;}
dish(){}
};
class hanoi
{
public:
HWND hwnd;
int i;//盘子数
int width;//基础长度
int heightbottomtop;
int xcyc;
POINT x1[3];
POINT x2[3];
POINT y1[3];
POINT y2[3];
stack A[3];//柱子A
hanoi(){}
hanoi(int xint yint zHWND hnd)
{
i=x;xc=y;yc=z;
hwnd=hnd;
width=xc/10;
height=yc*0.7;
bottom=yc*0.8;
top=bottom-height;
x1[0].x=width*2;x1[0].y=bottom;x2[0].x=width*3;x2[0].y=bottom;
x1[1].x=width*4;x1[1].y=bottom;x2[1].x=width*5;x2[1].y=bottom;
x1[2].x=width*6;x1[2].y=bottom;x2[2].x=width*7;x2[2].y=bottom;
y1[0].x=width*2.5;y1[0].y=bottom;y2[0].x=width*2.5;y2[0].y=top;
y1[1].x=width*4.5;y1[1].y=bottom;y2[1].x=width*4.5;y2[1].y=top;
y1[2].x=width*6.5;y1[2].y=bottom;y2[2].x=width*6.5;y2[2].y=top;
for(int j=0;j {
dish temp(j(width*(i-j)/i));
A[0].push(temp);
}
}//这是初始化,其实好友许多没有初始化。。。
void init(){
InvalidateRect (hwnd NULL TRUE) ;
MessageBox(hwnd“开始移动!!!!“““MB_OK);
move(i012);
}
void move(int nint aint bint c)
{
if(n>0)
{
move(n-1acb);
Sleep(speed);
dish temp=A[a].top();
A[a].pop();
A[b].push(temp);
InvalidateRect (hwnd NULL TRUE) ;
move(n-1cba);
}
}
};
hanoi* res;
DWORD WINAPI Thread (PVOID pParam)
{
flag=true;
res->init();
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance
HINSTANCE hPrevInstance
LPSTR lpCmdLine
int
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-11-12 13:30 hanoi\
文件 5132 2010-11-12 13:29 hanoi\hanoi.aps
文件 9079 2010-11-12 13:10 hanoi\hanoi.cpp
文件 4470 2010-11-12 13:18 hanoi\hanoi.dsp
文件 533 2010-11-12 09:28 hanoi\hanoi.dsw
文件 323 2010-11-12 09:28 hanoi\hanoi.h
文件 1078 2010-11-12 09:28 hanoi\hanoi.ico
文件 41984 2010-11-12 13:29 hanoi\hanoi.ncb
文件 48640 2010-11-12 13:29 hanoi\hanoi.opt
文件 906 2010-11-12 13:29 hanoi\hanoi.plg
文件 3419 2010-11-12 13:29 hanoi\hanoi.rc
文件 875 2010-11-12 13:19 hanoi\hanoi.sln
文件 7680 2010-11-12 13:22 hanoi\hanoi.suo
文件 6805 2010-11-12 13:19 hanoi\hanoi.vcproj
文件 2055 2010-11-12 09:28 hanoi\ReadMe.txt
文件 777 2010-11-12 09:28 hanoi\resource.h
文件 318 2010-11-12 09:28 hanoi\small.ico
文件 296 2010-11-12 10:29 hanoi\StdAfx.cpp
文件 1067 2010-11-12 10:28 hanoi\StdAfx.h
- 上一篇:c++利用遗传算法求解函数优化问题
- 下一篇:迷宫问题c语言源代码
相关资源
- 超级玛丽c++源码win32Linux平台
- [纯C语言 + Win32 API]一步一步写个围棋
- C++ 游戏疯狂的赛车
- Win32多线程程序设计--详细书签版
- Win32简易画图程序
- 我见过最漂亮的CS仿真程序openGL和C+
- libcurl-7.19.3-win32-ssl-msvc.zip
- VC++ 推箱子游戏源代码(双缓存版)
- VC++ Win32俄罗斯方块游戏源码(新)
- VC++2012版Prim算法最小生成树动态演示
- vc 最短路径演示程序源代码
- 自己编写的C++基于socket编程的UDP聊天
- win32 VC++ 合并 exe 和 Dll..
- MFC 约瑟夫环演示程序
- Tower_Hanoi.rar
- Twisted-19.2.1-cp38-cp38m-win32.whl
- php-5.3.5-Win32-VC6-x64
- WIN32程序的C++编程
- Microsoft Win32 程序员参考大全5.pdf(6个
- 音乐播放器源代码 vc++ 6.0
- win32应用程序中建立对话框
- Apache2.2-win32-x86
- Win32多线程程序设计 pdf高清
- gdi+游戏框架这是一个用vc6.0写的Win3
- 百度OCR文字识别依赖库-libcurl、opens
- MathGL2.2.2.1版的Win32 Lib,配合MathGL在
- N皇后问题可视化演示程序源代码
- win32编程之系统托盘图标显示以及弹出
- 汉诺塔移动动画 C++
- 在MFC中使用duilib
评论
共有 条评论