6-7 Isomorphic (20分)

 

 

 解题思路:递归判断

int Isomorphic( Tree T1, Tree T2 )
{
    if(!T1&&!T2)
    return 1;
    else if(T1&&!T2)
    return 0;
    else if(!T1&&T2)
    return 0;
    else
    {
        if(T1->Element==T2->Element)
        {
            return  (Isomorphic(T1->Left,T2->Left)||Isomorphic(T1->Left,T2->Right))&&(Isomorphic(T1->Right,T2->Left)||Isomorphic(T1->Right,T2->Right));
        }
        else
        return 0;     
    }
}

猜你喜欢

转载自www.cnblogs.com/snzhong/p/12743774.html
今日推荐