![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
简单.快乐
这个作者很懒,什么都没留下…
展开
-
数据结构 数组所有奇数放在所有偶数前面
#include <stdio.h>void move(int *a,int n){ int b[100]; int k=0; for(int i=0;i<n;i++) { if(a[i]%2==1) b[k++]=a[i]; } for(int i=0;i<n;i++) { if(a[i]%2==0) b[k++]=a[i]; } for(int i=0;i<n;i++) { a[i]=b[i]; }}int main()原创 2020-11-11 17:30:35 · 460 阅读 · 1 评论 -
数据结构 三元组转置
#include <stdio.h>#include <malloc.h>typedef struct Triple{ int i; int j; int e;};typedef struct TSMatrix{ Triple data[100]; int mu,nu,tu;//行列 非零个数 };//数组 转三元组 struct TSMatrix creatTS(int **a,int rows,int cols){ int sum=0; TSM原创 2020-11-11 17:17:25 · 876 阅读 · 0 评论 -
数据结构 对一个有序的单链表,删除所有值大于x而不大于y的结点
#include <stdio.h>#include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }; void visit(LNode* head){ if(head==NULL) return ; LNode *p=head->next; while(p!=NULL) { printf("%d ",p->data); p=p->next; } pr原创 2020-11-11 11:16:24 · 4824 阅读 · 0 评论 -
数据结构 在单链表中值为y的结点前插入一个值为x的结点
#include <stdio.h>#include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }; struct LNode* creat(int a[],int n){ LNode* head=(LNode*)malloc(sizeof(LNode)); LNode* p=head; for(int i=0;i<n;i++) { LNode* q=(LNode*)ma原创 2020-11-11 10:53:55 · 5254 阅读 · 1 评论 -
数据结构 创建二叉树 先序中序后序遍历 递归及非递归算法
#include <stdio.h>#include<malloc.h> #include<queue>#include<stack>using namespace std;typedef struct LNode{ int data; struct LNode *lchild, *rchild; }; //层序创建二叉树struct LNode* creat(int a[],int n){ if(n==0) return NUL原创 2020-11-10 23:09:00 · 526 阅读 · 0 评论 -
数据结构 删除单链表中一个最小值节点
#include <stdio.h>#include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }; //数组 构建成单链表 (带头结点) struct LNode* creat(int a[],int n){ LNode* head=(LNode*)malloc(sizeof(LNode)); LNode* p=head; for(int i=0;i<n;i++) {原创 2020-11-10 17:24:42 · 700 阅读 · 0 评论 -
数据结构 删除单链表相同值结点(只留一个,,删除其余相同结点)
#include <stdio.h>#include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }; //单链表中删除值相同节点void delete1(LNode *head){ LNode *p=head->next; int i=0; while(p) { LNode *q=p; while(q->next) { if(p->data.原创 2020-11-07 23:45:43 · 935 阅读 · 0 评论 -
数据结构 合并有序链表
#include <stdio.h>#include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }; struct LNode* creat(int a[],int n){ LNode* head=(LNode*)malloc(sizeof(LNode)); LNode* p=head; for(int i=0;i<n;i++) { LNode* q=(LNode*).原创 2020-11-07 21:35:10 · 283 阅读 · 0 评论 -
非伪代码 队列的定义及基本操作
队列的定义及基本操作记住先进先出就OK#include <stdio.h>#include <malloc.h>//节点 struct node { int data; node *next;};//链队列 struct queue{ node *front; node *rear;};//初始化queue* initQueue(){ q...原创 2020-03-07 13:00:47 · 186 阅读 · 0 评论 -
1 线性表-----单链表
线性表-----单链表#include <stdio.h>#include <malloc.h>//单链表struct LNode{ int data; struct LNode *next;}; //初始化 void InitLinkList(LNode *head) { if(head->next==NULL) return; he...原创 2020-03-02 18:37:47 · 177 阅读 · 0 评论 -
1 线性表-----顺序表
线性表-----顺序表#include <stdio.h>#define max 10//顺序表定义typedef struct Sqlist{ int data[max]; int length;}Sqlist; //初始化 void initList(Sqlist &L) { L.length = 0;}//显示所有数据 void disp...原创 2020-03-02 18:38:20 · 153 阅读 · 0 评论