#include"iostream"
using namespace std;
struct node
{
struct node * pre;
struct node * next;
int valuenumber;
};
#define Sizenum 100
int datanode[Sizenum];
node nodepool[Sizenum];
node nil;
node *NIL;
int index = 0;
void newrandnumber()
{
/*
for (int i = 0; i < SIZE; i++)
{
for (int j = 0; j < 5; j++)
data[i][j] = rand() % 26 + 'a';
}
*/
for (int i = 0; i < Sizenum; i++)
{
datanode[i] = rand() % 100;
}
cout << "生成随机数完成!" << endl;
}
void initnode()
{
index = 0;
NIL = &nil;
NIL->next = NIL->pre = NIL;
cout << "initnode完成!" << endl;
}
node * getnewnode(int key)
{
nodepool[index].valuenumber = key;
return &nodepool[index++];
}
void linkNode()
{
cout << "linkNode start" << endl;
node * indexnode=NIL;
for (int i=0; i < Sizenum; i++)
{
node * temp = getnewnode(datanode[i]);
temp->pre = indexnode;
temp->next = NIL;
indexnode->next = temp;
NIL->pre = temp;
indexnode = temp;
}
cout << "linkNode doan!!!" << endl;
}
void printf()
{
int k=0;
node * cur = NIL->next;
while (cur != NIL&&k<Size)
{
cout <<"datanode : " <<datanode[k++]<<" ,node: "<<cur->valuenumber << endl;
cur = cur->next;
}
cout << "printf done!!!" << endl;
}
void sort()
{
cout << "Now we sort start..." << endl;
}
int main()
{
newrandnumber();
initnode();
linkNode();
printf();
return 0;