본문 바로가기

하노이탑3

[개탱][C언어][하노이탑][간단한 알고리즘][재귀][Stack][스택][그래픽화][그래픽][도형] 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816.. 2017. 12. 21.
[개탱][C언어][하노이탑][간단한 알고리즘][재귀호출][재귀함수][Stack][스택] 재귀호출을 사용한 하노이탑123456789101112131415161718192021222324#define _CRT_SECURE_NO_WARNINGS#include #include int n;void hanoi(int n, char from, char tmp, char to);int iNum;int main() { // '1', '2', '3' scanf("%d",&n); printf("%d\n",(int)pow(2,n)-1); hanoi(n,'1','2','3');}void hanoi(int n, char from, char tmp, char to){ if(n==1) { printf("%c %c\n",from,to); iNum++; return; } hanoi(n-1,from,to,tmp); hano.. 2017. 12. 21.
[개탱][C언어][하노이탑][간단한 알고리즘][비재귀][Stack][스택][while] 재귀호출을 사용하지 않고 while 문을 사용한 하노이탑 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172#define _CRT_SECURE_NO_WARNINGS#include #include #include using namespace std;int n;//void hanoi(int n, char from, char tmp, char to); typedef struct tagInfo { int iNum; int iFrom; int iTemp; int iTo; int iMod; tagInfo(){}; tagInfo.. 2017. 12. 21.