#include
typedef struct {
int rank;
int p;
int ehead;
int next;
int eend;
int size;
int peri;
} uni_elt;
typedef struct{
int position;
int neighbor;
int inner;
} uni_peri;
class universe {
public:
universe(int elements, int wid);
~universe();
int find(int x);
void join(int x, int y);
int size(int x) const { return elts[x].size; }
int num_sets() const { return num; }
int calperi(int x);
private:
uni_elt *elts;
int num;
int width;
};
universe::universe(int elements, int wid) {
elts = new uni_elt[elements];
num = elements;
width = wid;
for (int i = 0; i < elements; i++) {
elts[i].rank = 0;
elts[i].size = 1;
elts[i].p = i;
elts[i].peri = 1;
elts[i].ehead = i;
elts[i].next = i;
elts[i].eend = i;
}
}
universe::~universe() {
delete [] elts;
}
#include "stdafx.h"
int main(int argc, char* argv[])
{
int h = 3;
int w = 7;
int result;
universe *u = new universe(h*w, w); //加了一个变量width
return 0;
}