/* 2009 ³âµµ C++ Áß°£°í»ç ¼º¸í ( ) Çйø ( ) ¹®Á¦ Key ( ) */ /* ´ÙÀ½ ¸ðµç ¹®Á¦¿¡ ´ëÇÏ¿© 12345 ¼ö¸¦ Àڱ⠹®Á¦ Key ¼ö·Î ¹Ù²Û ÈÄ ¹®Á¦¸¦ Ǫ½Ã¿À. */ /* ¹®Á¦Áö¿¡ ³«¼­ÇÏÁö ¸»°Í */ /* 1. ´ÙÀ½ ÇÁ·Î±×·¥ÀÇ Ãâ·ÂÀ» ½á¶ó. */ #include int number[5] = { 1, 2, 3, 4, 5 }; // ¿©±â¸¦ ¹Ù²Ü °Í void moveHanoi(int n,char from,char temp,char to) { if (n == 1) { printf("%d\n",number[0]); return; } printf("%d\n",number[1]); moveHanoi(1,from,temp,to); printf("%d\n",number[2]); moveHanoi(n-1,from,to,temp); printf("%d\n",number[3]); moveHanoi(n-1,temp,from,to); printf("%d\n",number[4]); } void main() { moveHanoi(2,'A','B','C'); }