#include  < iostream >
using   namespace  std;

const   int  MAXN  =   100 ;

class  UFset
{
public :
    
int  parent[MAXN];
    UFset();
    
int  Find( int );
    
void  Union( int int );
}
;

UFset::UFset()
{
    memset(parent, 
- 1 sizeof (parent));
}


int  UFset::Find( int  x)
{
    
if  (parent[x]  <   0 )
        
return  x;
    
else
    
{
        parent[x] 
=  Find(parent[x]);
        
return  parent[x];
    }
//  压缩路径
}


void  UFset::Union( int  x,  int  y)
{
    
int  pX  =  Find(x);
    
int  pY  =  Find(y);
    
int  tmp;
    
if  (pX  !=  pY)
    
{
        tmp 
=  parent[pX]  +  parent[pY];  //  加权合并
         if  (parent[pX]  >  parent[pY])
        
{
            parent[pX] 
=  pY;
            parent[pY] 
=  tmp;
        }

        
else
        
{
            parent[pY] 
=  pX;
            parent[pX] 
=  tmp;
        }

    }

}


int  main()
{
    
return   0 ;
}
有bug请指正:)