NetSecurity 板


LINE

※ [本文转录自 blueseami 看板] 作者: tung (2006梦想起飞~~) 站内: blueseami 标题: 生日快乐 时间: Mon Apr 10 01:02:58 2006 #include<iostream.h> #include<iomanip.h> #include<fstream.h> #include"stack.h" char* FileNameIn="maze.txt"; struct matrix { int data1; int data2; char chose; }; int main() { STACK* path; path=createstack(); STACK* section; section=createstack(); fstream FileInput(FileNameIn, ios::in); int maze[10][12]; int col=0; int row=0; while(FileInput.peek()!=EOF || row!=10 || col!=1) { if(col==12) { row++; col=0; if(row==10 && col==0) break; } FileInput>>maze[row][col]; col=col+1; } for(int i=0;i<10;i++) { for(int j=0;j<12;j++) { cout<<setw(2)<<maze[i][j]; } cout<<endl; } int m,n,p,q,count,x,y; m=0;n=0;p=0;q=0;count=0;x=0;y=0; matrix step[150]; int cstep=0; matrix* last; matrix* last1; cout<<"2 is exit:(4,11)"<<endl; cout<<"enter entrance ex:(1,1)"<<endl; cin>>m>>n; cout<<"the path of the astray mouse"<<endl; step[cstep].data1=m; step[cstep].data2=n; step[cstep].chose='A'; last1=&step[cstep]; pushstack(section,&step[cstep]); while(maze[m][n]!=2) { p=m+1;q=n; if((maze[p][q]==0 || maze[p][q]==2) && (p!=last1->data1 || q!=last1->data2)) { cstep++; step[cstep].data1=p; step[cstep].data2=q; step[cstep].chose='B'; pushstack(section,&step[cstep]); x=p;y=q; count++; } p=m;q=n+1; if((maze[p][q]==0 || maze[p][q]==2) && (p!=last1->data1 || q!=last1->data2)) { cstep++; step[cstep].data1=p; step[cstep].data2=q; step[cstep].chose='B'; pushstack(section,&step[cstep]); x=p;y=q; count++; } p=m-1;q=n; if((maze[p][q]==0 || maze[p][q]==2) && (p!=last1->data1 || q!=last1->data2)) { cstep++; step[cstep].data1=p; step[cstep].data2=q; step[cstep].chose='B'; pushstack(section,&step[cstep]); x=p;y=q; count++; } p=m;q=n-1; if((maze[p][q]==0 || maze[p][q]==2) && (p!=last1->data1 || q!=last1->data2)) { cstep++; step[cstep].data1=p; step[cstep].data2=q; step[cstep].chose='B'; pushstack(section,&step[cstep]); x=p;y=q; count++; } pushstack(path,&step[cstep-count]); m=x;n=y; if(count==1) { ((matrix*)section->top->data)->chose='A'; last1=(matrix*)stacktop(path); } if(count>1) { last=(matrix*)popstack(section); m=last->data1; n=last->data2; last->chose='A'; pushstack(section,&step[cstep-count]); pushstack(section,last); last1=(matrix*)stacktop(path); } if(count==0) { last=(matrix*)popstack(section); while(((matrix*)section->top->data)->chose=='A') { last=(matrix*)popstack(section); pushstack(path,last); last1=last; } last=(matrix*)popstack(section); pushstack(section,last); last->chose='A'; m=(last->data1); n=(last->data2); cstep++; step[cstep]=*last1; cstep++; step[cstep]=*last; } count=0; } pushstack(path,&step[cstep]); STACK* mouse; mouse=createstack(); cout<<"entry"<<endl; while(path->count>=1) { last=(matrix*)popstack(path); pushstack(mouse,last); } while(mouse->count>=1) { last=(matrix*)popstack(mouse); cout<<"("<<last->data1<<","<<last->data2<<")"<<endl; } cout<<"goal"<<endl; while(section->count>=1) { last1=(matrix*)popstack(section); } destroystack(mouse); destroystack(path); destroystack(section); return 0; } ----------------------------- 自己要用txt档作一个像课本上面的迷宫 1是墙 0是通道 2是出口 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 2 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 免费再赠送迷宫一个 记得在做迷宫的时候 不要弄得太怪 因为我写的程式很笨(我没把那种东西考虑进去..冏rz) 如果有路径是可以互通的 那就会无穷回圈 只要有分支的路就可以了 不要太复杂 1 -- 风信游子(bbs.cm.nctu.edu.tw)Post From: 140.113.92.21 ★ → tung: 你们可以把我的step[]改成pointer [04/10] → tung: 因为我上礼拜再写的时候 为了保险他一定写的出来 [04/10] → tung: 用比较安全的写法...後来程式码太大就不想改了 [04/10] → blueseami: 感谢你.......没写到你当真了 [04/10] → blueseami: 超级棒的生日礼物ㄟ [04/10] → blueseami: 我会好好参悟一下 [04/10] → tung: 我怕你们会笑我程式写的很丑 因为我没有先写演算法 [04/10] → tung: 我都是想到什麽写什麽进去的...所以看起来会很乱 [04/10] → tung: 但是功能一定有啦!! [04/10] → blueseami: 我哪敢笑...... [04/10] → blueseami: 我还写不出来勒 [04/10] -- ≡中女一北≡ 0351801乐 -- 风信游子(bbs.cm.nctu.edu.tw)Post From: 140.113.68.3







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草
伺服器连线错误,造成您的不便还请多多包涵!
「赞助商连结」






like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP