65,211
社区成员
发帖
与我相关
我的任务
分享
struct node
{
int i;
struct node * next;
};
struct node * head;
void insert(int x)
{
struct node * n = malloc(sizeof(node));
struct node * tail;
if(head)
{
tail = head;
while(tail->next)
tail = tail->next;
tail->next = n;
}
else
head = n;
n->i = x;
n->next = NULL;
}
class list
{
public:
void insert(int i)
{
node * n = new node;
if(head)
{
node * tail = head;
while(tail->next)
tail = tail->next;
tail->next = n;
}
else
head = n;
n->i = x;
n->next = 0;
}
private:
node * head;
};
list list_object;
list_object.insert(1);