??????????洢?????
???????????? ???????[ 2016/11/7 10:24:15 ] ????????????? ????洢
?????洢??????????????????????洢??????臨???????????????????????漰?????????????????????????洢???????漰????????????????????????洢??????????????洢?????????????е????????????
???????????????洢??????????????????а???
????// ????.cpp : ??????????ó????????
????//
????#include "stdafx.h"
????#include "stdlib.h"
????#include "iostream"
????using namespace std;
????typedef struct LNode {
????int data;
????struct LNode *next;
????}LinkList;
????LinkList *p?? *q?? *head;
????//?????????
????void InitList(LinkList &L)
????{
????head = (LinkList *)malloc(sizeof(LinkList));
????if (head==NULL)
????{
????exit(0);
????}
????head->next = NULL;
????}
????//??????β???????
????void InsertLastList(LinkList &L?? int e)
????{
????p = q = (LinkList *)malloc(sizeof(LinkList));
????p = head;
????if (p==NULL)
????{
????exit(0);
????}
????while (p->next!=NULL)
????{
????p = p->next;
????}
????q->data = e;
????q->next = p->next;//NULL
????p->next = q;
????}
????//??????????????
????void InsertFirstList(LinkList &L?? int e)
????{
????p = (LinkList *)malloc(sizeof(LinkList));
????if (head==NULL)
????{
????exit(0);
????}
????p->data = e;
????p->next = head->next;
????head->next = p;
????}
????//????????
????void ShowList(LinkList L)
????{
????p = (LinkList *)malloc(sizeof(LinkList));
????p = head->next;
????if (p==NULL)
????{
????exit(0);
????}
????while (p!=NULL)
????{
????cout << p->data << " ";
????p = p->next;
????}
????cout << endl;
????}
????//????????????
????int ListLength(LinkList L)
????{
????int count = 0;
????p = (LinkList *)malloc(sizeof(LinkList));
????p = head;
????while (p->next!=NULL)
????{
????count++;
????p = p->next;
????}
????return count;
????}
????//??e?????i?????
????void GetElem(LinkList L?? int i?? int &e)
????{
????int j = 1;
????p = (LinkList *)malloc(sizeof(LinkList));
????p = head->next;
????while (p&&j<i)
????{
????p = p->next;
????j++;
????}
????if (!p||j>i)
????{
????exit(0);
????}
????else
????{
????e = p->data;
????}
????free(p);
????}
????//??iλ?ò???e???
????void ListInsert(LinkList &L?? int i?? int e)
????{
????p = head;
????int j = 0;
????while (p&&j<i-1)
????{
????p = p->next;
????++j;
????}
????if (!p||j>i-1)//??i??????????
????{
????exit(0);
????}
????q = (LinkList *)malloc(sizeof(LinkList));
????q->data = e;
????q->next = p->next;
????p->next = q;
????}
????//?????i?????
????void ListDelete(LinkList &L?? int i??int &e)
????{
????p = head;
????int j = 0;
????while (p&&j<i-1)
????{
????p = p->next;
????++j;
????}
????if (!p||j>i-1)
????{
????exit(0);
????}
????q=p->next;
????p->next = q->next;
????e = q->data;
????free(q);
????}
????//????????
????void DestroyList(LinkList &L)
????{
????q = p = (LinkList *)malloc(sizeof(LinkList));
????p = head;
????q = p->next;
????while (q!=NULL)
????{
????free(p);
????p = q;
????q = p->next;
????}
????free(q);
????}
????int main()
????{
????LinkList L;
????InitList(L);
????int num[6] = { 0??5??3??4??7??3 };
????for (size_t i = 0; i < sizeof(num)/sizeof(num[0]); i++)
????{
????InsertLastList(L?? num[i]);
????}
????ShowList(L);
????InsertFirstList(L?? 1);
????ShowList(L);
????cout << ListLength(L) << endl;
????ListInsert(L?? 2?? 99);
????int e;
????ListDelete(L?? 2?? e);
????ShowList(L);
????DestroyList(L);
????return 0;
????}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11