正在加载图片...
include <iostream.h> #include strclass. h void Hanoi (int n, String A, string B, string C) {M解决汉诺塔问题的算法 if (n==1)cout <<"move <<a<< to <<C<< endl elsei Hanoi(n-1, A, C, B); cout <<move <<a<<to << c <K endl: Hanoi(n-1, B, A,C);#include <iostream.h> #include "strclass.h” void Hanoi (int n, String A, String B, String C ) { //解决汉诺塔问题的算法 if ( n == 1 ) cout << " move " << A << " to ” << C << endl; else { Hanoi ( n-1, A, C, B ); cout << " move " << A << " to " << C << endl; Hanoi ( n-1, B, A, C ); } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有