// fsdf.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#define SIZE 5
#include
struct Node{
int data;
Node *link;
};
Node* CreatList(int len)
{
int i=1;
Node *current=(Node *)malloc(sizeof(Node));
current->data=i;
current->link=NULL;
Node *first=current;
i++;
while (1)
{
if(i {
Node *temp=(Node *)malloc(sizeof(Node));
temp->data=i;
temp->link=NULL;
current->link=temp;
current=temp;
}
else if(i==len)
{
Node *temp=(Node *)malloc(sizeof(Node));
temp->data=i++;
temp->link=first;
current->link=temp;
current=temp;
}
else
break;
i++;
}
return first;
}
void main()
{
Node *first=CreatList(SIZE);
int size=SIZE;
while(1)
{
if(size>1)
{
first=first->link;
Node *p=first->link ;
first->link=p->link;
first=p->link;
size--;
}
else
break;
}
cout<data;
}
--------------------next---------------------
阅读(1014) | 评论(0) | 转发(0) |