
DS
C数据结构。
zxy131072
嵌入式linux
展开
-
单向链表操作
#include <stdlib.h>#include <string.h>#include <stdio.h>typedef struct Node{ int data; struct Node *next;}SLIST;SLIST *SList_Create(){ SLIST *pHead, *pM, *pCur; int data; //创建头节点 并初始化 pHead = (SLIST *)malloc(sizeof(SLIST)原创 2020-09-23 11:38:29 · 100 阅读 · 0 评论 -
C实现快速排序算法实现
#include <stdio.h>void QuickSort(int * a, int low, int high);int FindPos(int * a, int low, int high);void QuickSort(int * a, int low, int high){ int pos; if (low < high) { pos = FindPos(a, low, high); QuickSort(a, low, pos-1); Quic原创 2020-09-22 10:23:26 · 122 阅读 · 0 评论 -
静态链表使用
#include <stdio.h>typedef struct Teacher{ int data; struct Teacher *next;}Teacher;Teacher *CreatlIST(){ static Teacher t1, t2, t3; Teacher *p = NULL; t1.data = 1; t2.data = 2; t3.data = 3; t1.next = &t2; t2.next = &t3; t3.n原创 2020-09-22 10:17:16 · 75 阅读 · 0 评论 -
结构体嵌套结构体和嵌套结构体指针类型
#include <stdio.h>typedef struct Student { char name[64]; int id;}Student;typedef struct Teacher { char name[64]; int id; char *p; char **p2; Student s1; Student *p3;}Teacher;//1 结构体中套一个结构体//2 结构体的指针//3 结构中套一个 自己类型的结构体元素==err原创 2020-09-22 10:11:46 · 1668 阅读 · 0 评论 -
顺序链表的操作
/*线性表的顺序存储:顺序表*/#include <stdio.h>#include <stdlib.h> //malloc#if 0void *malloc(size_t size); 功能:在堆区开辟空间参数:size开辟空间的大小返回:返回堆区的首地址,需要强制类型转换#endif#define N 10//存储的数据类型typedef int data_t;//顺序表的类型typedef struct { data_t a[N]; /原创 2020-08-03 09:41:50 · 225 阅读 · 0 评论 -
单向链表基本操作
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct Node{ int id; //数据域 struct Node *next; //指针域}SLIST;//创建头节点SLIST *SListCreat() { SLIST *pCur = NULL; //当前节点 SLIST *pHe原创 2020-07-31 13:25:02 · 177 阅读 · 0 评论 -
静态链表使用
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct Stu{ int id; //数据域 char name[100]; struct Stu *next; //指针域}Stu;int main(void){ //初始化三个结构体变量 Stu s1 = { 1, "mike", NULL原创 2020-07-30 17:27:06 · 130 阅读 · 0 评论 -
数据结构内容
定义如何把现实中大量而复杂的问题以特定的数据类型和特定的存储结构保存到主存储器(内存)中,以及在此基础上为实现某个功能(比如查找某个元素,删除某个元素,对所有元素进行排序)而执行的相应操作, 这个相应的操作也叫算法数据结构 = 个体的存储 + 个体关系的存储算法 = 对存储数据的操作衡量算法的标准1. 时间复杂度 大概程序要执行的次数,而非执行的时间 2. 空间复杂度 算法执行过...原创 2020-01-10 14:11:15 · 273 阅读 · 0 评论