数据结构(C语言版)
数组,链表,树
回忆丶搁浅
这个作者很懒,什么都没留下…
展开
-
数据结构_二叉排序树
#include <stdio.h>#include <stdlib.h>typedef struct BiTNode{ int data; BiTNode *lchild,*rchild;}BiTNode,*BiTree;// 查找 void InsBST(BiTree *T,int data){ BiTNode *f,*p; p=(*T); while(p){ if(p->data==data){ printf("不需要插入已存在");.原创 2020-12-28 12:27:21 · 187 阅读 · 0 评论 -
数据结构_二叉树
#include <stdio.h>#include <stdlib.h>typedef struct BiTNode{ int data; BiTNode *lchild,*rchild;}BiTNode,*BiTree;BiTNode *CreatTree(){ BiTNode *t; int x; scanf("%d",&x); getchar(); if(x==0) t=NULL; else{ t =(BiTree)malloc(size.原创 2020-12-28 12:26:04 · 143 阅读 · 0 评论 -
数据结构_链队列
#include <stdio.h>#include <stdlib.h>typedef int QElemType; typedef struct QNode{ QElemType data; struct QNode * next;}QNode,*QueuePtr;typedef struct { QueuePtr front; QueuePtr rear;}LinkQueue;//初始化void InitQueue(LinkQu.原创 2020-12-28 12:23:22 · 126 阅读 · 0 评论 -
数据结构_栈
#include <stdio.h>#include <stdlib.h>typedef int SElemType;#define STACK_INIT_SIZE 100//存储空间初始分配量#define STACKINCREMENT 10//存储空间分配增量 typedef struct { SElemType *base; SElemType *top; int stacksize;}Sqstack;//构造一个空栈bool InitSta.原创 2020-12-28 12:17:51 · 120 阅读 · 0 评论 -
数据结构_双链表
#include <stdio.h>#include <stdlib.h>typedef int ElemType; typedef struct DNode { ElemType data; // 值 struct DNode *prior,*next; // 指向下一个结点 }DNode,*DLinklist;//头插法 DLinklist DList_HeadInsert(DLinklist &DL){ DNode *s; int x.原创 2020-12-28 12:14:08 · 110 阅读 · 0 评论 -
数据结构_单链表
#include <stdio.h>#include <stdlib.h>typedef int ElemType; typedef struct LNode { ElemType data; // 值 struct LNode *next; // 指向下一个结点 }LNode,*Linklist;// 头插法 倒序 Linklist List_HeadInsert(Linklist &L){ LNode * s; int x; L =.原创 2020-12-28 12:09:43 · 106 阅读 · 1 评论 -
C语言_算法_查找
1.在一个固定数组中查找这个数是否存在(1)顺序查找#include <stdio.h>int main() { int i,n,array[10]={1,2,3,4,5,6,7,8,9,10}; scanf("%d",&n); for(i=0;i<10;i++){ if(array[i]==n){ printf("第%d个\n",i+1); return 0; } } printf("无此数");}(2)折半查找#i原创 2020-07-22 16:40:18 · 135 阅读 · 0 评论 -
C语言_算法_排序问题
问题:有十个数,要求从小到大排序(1)方式一:冒泡法排序#include <stdio.h>int main() { int i,j,temp,a[10]={9,1,3,7,3,2,5,8,10,6}; printf("排序前:"); for(i=0;i<10;i++){ printf("%3d",a[i]); } for(j=0;j<9;j++){ for(i=0;i<9-j;i++){ if(a[i]>a[i+1]){ te原创 2020-07-21 10:42:44 · 212 阅读 · 0 评论