///¹þ·òÂü
#include "stdafx.h"
#include "stdlib.h"
int a[10];
struct node
{
int value;
int left;
int right;
};
struct linknode
{
node value;
linknode *next;
};
void sort(int a[],int index)
{
int temp = 0;
for (int i=index;i<10;i++)
{
for (int j=i;j<10;j++)
{
if (a[i]>a[j])
{
temp = a[i];
a[i] =a[j];
a[j] =temp;
}
}
}
}
int main(int argc, char* argv[])
{
linknode *root =(linknode *)malloc(sizeof(linknode));
linknode *list = root;
for (int i=0;i<10;i++)
{
a[i] =i+1;
}
for (int j=0;j<10;j++)
{
sort(a,j);
list->next =(linknode *)malloc(sizeof(linknode));
node temp;
temp.value = a[j] +a[j+1];
temp.right =a[j+1];
temp.left =a[j];
list->value =temp;
list =list->next;
a[j+1] =a[j] +a[j+1];