1 / 5
文档名称:

汉诺塔图形界面C源码交大项目.doc

格式:doc   大小:43KB   页数:5页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

汉诺塔图形界面C源码交大项目.doc

上传人:guoxiachuanyue001 2021/11/13 文件大小:43 KB

下载得到文件列表

汉诺塔图形界面C源码交大项目.doc

相关文档

文档介绍

文档介绍:: .
/*汉诺塔 图形界面 C++ 源码 VC 。 */ include<>
#include<>
#include<>
#include<>
#include<>
#include<> struct T
{
int h 。 //塔的高度
int x 。 //塔的第一个盘的 x 坐标 ,y 坐标等于 (7+n- 塔的高度 h) int l 。 //塔的第一个盘的长度 }ta[3]={{10,15,2},{0,0,0},{0,0,0}} 。
char c[18][79],hnt[18][79]={
{" "},
{" 汉诺塔动画演示 "},
"},
"}}
{" "},
{" I
{"「"},
{"「"},
{" II "},
{" !■! "},
{" I・I "},
{" IhmI "},
{" 〔■■■■I "},
{" [■■■■I "},
{" [■■■■■■I "},
[■■■■■■■I
"},
"},
"},
{" 1
int n 。
int sum=0 。
int computerorpeople=1 。
int speed=0 。
void count_ta_1(int ta_1)// 重新计算塔的第一个盘的 x 坐标和塔的高度 {
int i 。
int j 。
int k=0 。
for(i=7 。 i<7+n 。 i++)
for(j=4+ta_1*24 。 j<28+ta_1*24 。 j++)
{ if(hnt[i][j]!=' ')
{ for(。hnt[i][j+k]!=' ' 。k++)。
ta[ta_1].x=j 。
ta[ta_1].l=k 。
return 。 }
}
}
void move(int ta_1,int ta_3)
{
int i 。 sum++。
ta[ta_3].h++ 。
ta[ta_3].x=ta[ta_1].x+(ta_3-ta_1)*24 。 //每个塔之间相隔 4
ta[ta_3].l=ta[ta_1].l 。
for(i=0 。 i<ta[ta_1].l 。 i++)
{
hnt[7+n-ta[ta_3].h][ta[ta_3].x+i]=hnt[7+n-ta[ta_1].h][ta[ta_1].x+i] 。
hnt[7+n-ta[ta_1].h][ta[ta_1].x+i]=' ' 。
}
ta[ta_1].h-- 。
count_ta_1(ta_1) 。
system("cls") 。 for(i=0 。 i<7+n 。 i++)
cout<<hnt[i]<<endl 。
cout<<hnt[17] 。
cout<<endl<<endl<<" 从 "<<char(ta_1+65)<<" 塔 移 动 一 个 盘 到 "<<char(ta_3+65)<<" 塔 "<<endl 。
cout<<endl<<" 步数 :