Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
407 B
1
Indexable
Never
struct DJS
{
#define  MAX_DJS 100
	int data[MAX_DJS];
	void makeset(int x){ // tao 1 nut moi vao DJS
		data[x] =x; 
	}
	int findset(int x){ // tim nut cha
		if( x== data[x]) return x;
		else return findset(data[x]);
	}
	void _union(int x, int y){  //gom nut cha
		data[findset(y)] = findset(x);
	}
	void init(){   // khoi tao DJS
		for(int i=0; i<MAX_DJS; i++){
			data[i] =0;
		}
	}
}DJS