





下面的代码是前3张图的代码,谁能在次基础上帮我完成这个程序呀! 感谢了,有什么疑问可以联系我QQ:369710920
#include
#include
using namespace std;
#define N 8
#define R 0.2
#define maxSize 6
class list;
class well
{
private:
double x,y;
int num;
bool b;
public:
well():b(true){}
~well(){}
void input(){cin>>num>>x>>y;}
void output(){cout< void incorporate(){b=false;}
int getNum(){return num;}
double getX(){return x;}
double getY(){return y;}
double distance(well &a){return sqrt(pow((x-a.getX()),2.0)+pow((y-a.getY()),2.0));}
bool isInGroup(){return b;}
};
class node
{
friend list;
private:
well w[N];
int len;
node *next;
public:
node():len(0),next(NULL){}
~node(){}
void print();
void insert(well &x){w[len++]=x;}
bool judge(well&);
bool isFull(){return len==maxSize;}
};
bool node::judge(well &x)
{
int i;
for(i=0;i if(w.distance(x)>2*R) break;
return i==len;
}
void node::print()
{
for(int i=0;i cout<.getNum()<<' ';
cout<}
class list
{
private:
node *head,*last;
public:
list(){head=new node;last=head;}
~list();
node *getNode(){return last;}
int createNewNode();
void print();
};
int list::createNewNode()
{
node *p=new node;
if(p==NULL) return 0;
last->next=p;
last=p;
return 1;
}
void list::print()
{
node *p=head->next;
while(p!=NULL)
{
p->print();
p=p->next;
}
}
list::~list()
{
node *p=head->next;
while(p!=NULL)
{
head->next=p->next;
delete p;
p=head->next;
}
delete head;
}
int isComplete(well *w)
{
int i;
for(i=0;i if(w.isInGroup()) break;
return i;
}
int main()
{
well w[N];
list l;
int i,j;
for(i=0;i w.input();
for(i=0;i {
if((i=isComplete(w))==N) break;
l.createNewNode();
node *p=l.getNode();
p->insert(w);
w.incorporate();
for(j=i+1;j {
if(p->isFull()) break;
while(!w[j].isInGroup()) j++;
if(p->judge(w[j]))
{
p->insert(w[j]);
w[j].incorporate();
}
}
}
l.print();
return 0;
}