#include<stdio.h>#include<stdlib.h>#include<iostream>usingnamespacestd;inta[]={1,2,3,4,5,6,7,8,9};structnode{node(intxx):x(xx),next(NULL){}intx;node*next;};voidfun(){}intmain(){node*head=newnode(0);node*p=head;for(inti=0;i<9;i++){node*add=newnode(a[i]);p->next=add;p=add;}node*q=head;while(q){cout<<q->x<<"";q=q->next;}cout<<endl;p=head->next;q=p->next;while(p->next!=NULL){node*add=newnode(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<<add->x<<endl;p=q->next;q=p->next;}q=head;while(q){cout<<q->x<<"";q=q->next;}cout<<endl;return0;}[sts@bogon20160731]$g++0.cc[sts@bogon20160731]$./a.out0123456789//链表的准备3//新添加的结点69121518274501233456678991215182745//最后的情况[sts@bogon20160731]$