- 博客(5)
- 问答 (2)
- 收藏
- 关注
原创 实现快速排序
#include <stdio.h>typedef int ElemType;int Patition(ElemType A[], int low, int high){ ElemType pivot = A[low];//初始值 while (low < high) { while (low<high && A[high]>=pivot)//要加等于号 high--; A[low] = A[high];//跳出循环,交换位置 wh
2022-02-04 12:38:25
403
原创 实现冒泡排序
#include <stdio.h>void swap(int &a,int &b){ int temp; temp=a; a=b; b=temp;}void BubbleSort(int a[],int n){ int i,j; for(i=0;i<n-1;i++) { for(j=n-1;j>i;j--) { if(a[j-1]>a[j]) { swap(a[j-1],a[j]); } } }
2022-01-25 15:02:10
474
原创 队列的链式存储(带头结点)
#include <stdio.h>#include <stdlib.h>typedef int ElemType;typedef struct LNode { ElemType data; struct LNode* next;}LNode;typedef struct { LNode* front, * rear;}LinkQueue;//初始化队列void Init(LinkQueue &Q){ Q.front = Q.rear = (LNod
2022-01-14 13:20:51
273
原创 单链表按位置查找元素值
//按位置查找元素值(i=2)LinkList GetElem(LinkList L, int i)//查找链表第二个位置的元素值{ int j = 1;//为了遍历 LNode* p = L->next;//让p指向第一个结点 if (i == 0)//查找头结点 { return L; } if (i < 1)//负值 { return NULL; } while (p != NULL && j < i) { p = p->ne
2022-01-04 13:13:39
1029
转载 数据结构链表中的结构体
链表结构体中LNode,*LinkList什么含义参考:https://blog.csdn.net/qq_41148224/article/details/91398523https://blog.csdn.net/GRoads/article/details/104155255typedef作用:起别名将struct LNode重命名为LNode将struct LNode* 重命名为LinkList(把LNode*连起来看)...
2021-12-30 22:08:55
204
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人