#include <iostream>
#include <fstream>
using namespace std;
void hanoi(char from, char by, char to, int num)
{
if(num==1)
{
fout<<num<<" : "<<from<<" -> "<<to<<endl;
}
else
{
hanoi(from, to, by, num-1);
fout<<num<<" : "<<from<<" -> "<<to<<endl;
hanoi(by, from, to, num-1);
}
}
void main()
{
int N;
ifstream fin;
ofstream fout;
fin>>N;
fin.open("input.txt");
fout.open("output.txt");
hanoi('A','B','C',N);
fin.close();
fout.close();
}
하노이탑 구현하고잇는데요 . 파일입출력썼을때 앞에 함수 fout이 먼저나와서 안되는것같은데 어떻게 처리해야할까요? ㅠㅠ
답변좀해주세요.. 멘붕중ㅜㅜ
c++기본서 참조해보면 충분히 아실 수 있을거같은디..