Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
(5)电子老鼠闯迷宫.cpp
Package: datastruct1 [view]
Upload User: wxj1219
Upload Date: 2013-01-31
Package Size: 6k
Code Size: 1k
Category:
Data structs
Development Platform:
C/C++
- #include<stdio.h>
- #include<conio.h>
- void pop(void);
- void push(void);
- void print(void);
- unsigned char a[8][8]=
- {
- {0,0,1,1,1,1,1,1},
- {1,0,1,0,0,0,0,1},
- {1,0,1,0,1,0,1,1},
- {1,0,0,0,0,0,1,1},
- {1,0,1,0,1,0,1,1},
- {1,0,1,0,1,0,1,1},
- {1,0,0,0,1,0,0,0},
- {1,0,1,0,0,0,1,0}
- };
- char addx[4]={0,1,0,-1};
- char addy[4]={-1,0,1,0};
- char x=0,y=0;
- char p=0;
- char stack[300];
- char u;
- void main()
- {
- clrscr();
- sta:if((y==7)&&(x==7))
- {
- print();
- getchar();
- goto end;
- }
- if((x<0)||(x>7)||(y<0)||(y>7)||(a[y][x]!=0))
- goto end;
- for(u=0;u<4;u++)
- {
- push();
- a[y][x]=2;
- x+=addx[u];
- y+=addy[u];
- goto sta;
- bac: ;
- }
- end:if(p>0)
- {
- pop();
- a[y][x]=0;
- goto bac;
- }
- }
- void push(void)
- {
- stack[p]=x;
- stack[p+1]=y;
- stack[p+2]=u;
- p+=3;
- }
- void pop(void)
- {
- p-=3;
- x=stack[p];
- y=stack[p+1];
- u=stack[p+2];
- }
- void print(void)
- {
- int u1,u2;
- for(u2=0;u2<8;u2++)
- {
- for(u1=0;u1<8;u1++)
- {
- gotoxy(u1+1,u2+1);
- if((a[u2][u1]==0)||(a[u2][u1]==2)) printf("%c",' ');
- if(a[u2][u1]==1) printf("%c",'