RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
【list】可用于哈夫曼树的一种建树选数的链表方法替代堆
#include
#include
#include
using namespace std;
int a[]={1,2,3,4,5,6,7,8,9};
struct node
{
node(int xx):x(xx),next(NULL){}
int x; 
 node *next;
};
void fun()
{
 
}
int main()
{
node *head=new node(0);
node *p=head;
for(int i=0;i<9;i++)
{
node *add=new node(a[i]);
p->next=add;
p=add;
}

 node *q=head;
while(q)
{
cout<x<<" ";
q=q->next;
}
cout<next;
q=p->next;
while(p->next!=NULL)
{

node *add=new node(p->x+q->x);
node  *qq=q; 
 while(add->x > qq->x && qq->next!=NULL)
     {
      qq=qq->next;
     }
  add->next=qq->next;
  qq->next=add;
  cout<x<next;
q=p->next;
}


 q=head;
while(q)
{
cout<x<<" ";
q=q->next;
}
cout<            
            
                                                            
网站题目:【list】可用于哈夫曼树的一种建树选数的链表方法替代堆
网站网址:http://scyingshan.cn/article/pgghce.html