7 條題解

  • 0
    @ 2025-5-17 11:46:07
    #include<bits/stdc++.h>
    using namespace std;
    void h(int x,char a,char b,char c)
    {
    	if(x==1)
    	{
    		cout<<a<<"->"<<x<<"->"<<b<<endl;
    	}
    	else
    	{
    		h(x-1,a,c,b);
    		cout<<a<<"->"<<x<<"->"<<b<<endl;
    		h(x-1,c,b,a);
    	}
    }
    int main()
    {
    	int n;
    	char a,b,c;
    	cin>>n>>a>>b>>c;
    	h(n,a,b,c);
    	return 0;
    }
    
    

    資訊

    ID
    940
    時間
    1000ms
    記憶體
    256MiB
    難度
    3
    標籤
    (無)
    遞交數
    134
    已透過
    42
    上傳者