Home > Back-end >  The design and implementation of a hash table data structure
The design and implementation of a hash table data structure

Time:10-03

 
after running the program, 2 function of some function can't use, please correct,
# # pragma warning (4996) disable: include # include # include # include & lt; Windows. H>
# include//screen clearing function header file # include & lt; String. H> using namespace std; # define MAX 100 # define MAXSIZE 20//phone book record number # define MAX_SIZE 20//the maximum length of names # define HASHSIZE 53/long/definition table # define OVERFLOW - 1 typedef struct Stuff {char name [20].//employee name char phone [25];//employee phone char add [10];//employee address struct Stuff * next; } Node, * Lnode; Lnode hash []; # define OK 1 # define the ERROR 0 # define STACK_INIT_SIZE 100 # define STACKINCREMENT 10
//# define OVERFLOW 49 # define N - 1 # define M 49 using namespace STD. Int maze [M] [N]. typedef int Status; Typedef struct
{int m, n, direc. } MazeType, * LMazeType; Typedef struct {LMazeType top; LMazeType base; Int stacksize; Int over; } the Stack;
Void Init_hand_Maze (int maze [M] [N], int M, int N)
{int I, j; For (I=1; I & lt;=m + 1; I++) for (j=1; J & lt;=n + 1; J++)
{as [I] [j]=1; } cout & lt; <"Please press line enter the maze, 0 means pathway, 1 obstacle:" & lt; For (I=1; i As [I] [j]; For (I=1; i{the for (j=1; jVoid Init_automatic_Maze (int maze [M] [N], int M, int N)//generated automatically maze
{int I, j;//cout & lt; <"\ n maze generation... \ n \ n ";//system (" pause "); For (I=1; i{int I, j; Cout & lt; <"Maze as shown." & lt; if (! S.b ase) exit (OVERFLOW); S.t op=S.b ase; S.s tacksize=STACK_INIT_SIZE; S.o ver=0; return OK; } the Status Push (Stack & amp; S, MazeType e) {if (S.t op - S.b ase & gt;=S.s tacksize) {S.b ase=(LMazeType) realloc (S.b ase, (S.s tacksize + STACKINCREMENT) * sizeof (MazeType)); if (! S.b ase) exit (OVERFLOW); S.t op=S.b ase + S.s tacksize; S.s tacksize +=STACKINCREMENT; } * S.t op++=e; return OK; Pop (Stack is} the Status & amp; S, MazeType & amp; (e) {if S.t op==S.b ase) return the ERROR; E=* - S.t op; return OK; }
The Status MazePath (Stack & amp; S, MazeType & amp; E, int maze [M] [N], int M, int N) {do {the if (maze [e.m] [e.n]==0)//0 can connect, 1 shall not pass, 2 for the past {Push (S, e); Maze [e.m] [e.n]=2; If (e.m==m& & E.n==n) {S.o ver=1;//says a path to fill the return OK; } else {e.n + +; E.d irec=0;//to this direction, 0 right under 1 2 3 left MazePath (S, e, maze, m, n); }} else {the if (S.t op!=S.b ase& & S.o ver!=1) {switch (e.d irec)//back to a place and at the same time to change direction next {0 case: e.n -; E.m + +; E.d irec=1; break; Case 1: e.m -; E.n -; E.d irec=2; break; Case 2: e.n + +;
E.m -; E.d irec=3; break; Case 3: Pop (S, e); break; }}}} while (S.t op!=S.b ase& & S.o ver!=1); return OK; }
Int PrintPath (Stack S, int maze [M] [N], int row, int col) {if (S.t op==S.b ase) {cout & lt; <"\ n===============================================\ n"; Cout & lt; <"This maze unanswered \ n \ n"; return ERROR; } MazeType e;
While (S.t op!=S.b ase) Pop (S, e); Maze [e.m] [e.n]=(e.d irec + 10); } cout & lt; <"Done!" For (j=1; jCase10: cout & lt; <"->"; break; Case 11: cout & lt; <"Left"; break; Case 12: cout & lt; <"Please"; break; Case 13: cout & lt; <"Write". break; }} cout & lt; Cout & lt; <"Entry" & lt; {cout & lt; <"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n"; Cout & lt; <"Welcome to maze solving system \ n"; Cout & lt; Cout & lt; <"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n"; Cout & lt; <"\ n"; Cout & lt; <"Please select your operating: \ n"; Cin & gt;> i; {switch (I) in case 1: cout & lt; <"\ n please enter the number of lines:"; Cin & gt;> m; Cout & lt; <"\ n"; Cout & lt; <"Please input the number of columns:"; Cin & gt;> n; While ((m<1 | | m> 49) | | (n<1 | | n> 49)) {cout & lt; <"\ n I'm sorry, you enter the ranks of the number is beyond the preset range (1-49, 1-49), please enter again: \ n \ n"; Cout & lt; <"\ n please enter the number of lines:";
Cin & gt;> m; Cout & lt; <"\ n"; Cout & lt; <"Please input the number of columns:"; Cin & gt;> n; } Init_hand_Maze (maze, m, n); PrintMaze (maze, m, n); MazeType start and end; Cout & lt; <"Please enter the starting point m n:" & lt; Start. M & gt;> Start. N; Start. The direc=0; Cout & lt; <"Please input the end m n:" & lt; End. M & gt;> The end. N; Stack S; Cout & lt; <"Looking for path... "& lt;
  • Related