Non-recipient non-stack algorithm for Hanno Tag (1)

zhaozj2021-02-16  49

#include #include #define maxno 10000INT Step_d, step_s, no; // Define the number of steps to travel void main () {cout << "Please enter the number (1-64): "; Cin >> NO; / / Get the actual number of tabs // initialization

INT ** P = new int * [3];

P [0] = new int in INT [NO 1];

P [1] = new int [NO 1];

P [2] = new int [NO 1]; P [0] [0] = MaxNO; P [1] [0] = MaxNO; P [2] [0] = MaxNo; for (int count = 1; Count ) {p [0] [count] = no-count 1; p [1] [count] = 0; P [2] [count] = 0;} // Initialization, IF (FMOD) (NO, 2)) {Step_s = 2; STEP_D = 1;} else {step_s = 1; step_d = 2;} // Judgment the number of steps of the odd disk and the number of steps of the idiogram INT from, TO; from = 0; TO = step_s from; p [0] = & p [0] [no]; while (* (p [0])! = * (p [1])) {cout << "from the column:" << from 1 << "to the column:" << to 1 << Endl; * ( p [to]) = * (p [from]); * (p [from] -) = 0; // The following steps will be taken to move to move to move to the post 2: if (* (p [1])) <* (p [1])) from = 0; Else from = 1; Break; Case 1: IF (* (p [0]) <* (p [2])) from = 0; else from = 2; Break; case 0: IF (* (p [2]) <* (p [1])) From = 2; Else from = 1; Break;} // The following row questions will be moved to the column IF (FMOD (* (* (p [wrom]), 2)) to = FMOD (from step_s, 3) ELSE to = FMOD (from step_d, 3);} char C; cin >> c;}

转载请注明原文地址:https://www.9cbs.com/read-21957.html

New Post(0)