![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言实现
文章平均质量分 55
眼眸印着温柔
天道酬勤
展开
-
二叉树的四种常考遍历方式以及习题整理
二叉树基础常考习题:1. 单值二叉树。Oj链接用根的值与左右字树的值进行判断; 看是否都相等class Solution {public: bool isU(struct TreeNode* root, int key){ if (root == NULL) return true; return root->val == key && isU(root->left, key) && isU(root->right, k原创 2021-05-02 21:15:58 · 803 阅读 · 0 评论 -
C语言的函数声明
C语言的函数定义和函数声明C语言不同于Java语言,在Java语言中,在一个类中,定义函数/方法后,在调用时不需要声明。在C语言中定义函数后,在使用前,需要在main函数前进行声明,否则会报错。#include <stdio.h>#include <stdlib.h>#include <string.h>void PrintArr(int* arr, int size) { for (int i = 0; i < size;i++) { print原创 2020-10-05 15:01:23 · 6117 阅读 · 0 评论 -
常见的7种排序算法
第七种排序: 归并排序基本思想: 先进行分解然后进行合并,合并时需要知道两个有序子序列的空间:[begin,mid],[mid+1,end] temp为辅助空间#include <stdio.h>#include <stdlib.h>#include <memory.h>//打印数组void PrintArr(int* arr, int size) { for (int i = 0; i < size;i++) { printf("%d ", a原创 2020-10-01 21:43:29 · 191 阅读 · 0 评论 -
实现一个函数来调整该数组中数字的顺序,使得所有的偶数位于数组的前半部分,所有的奇数位于位于数组的后半部分,
题目描述实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变基本思想: 先找到奇数的一组,在找到偶数的一组,然后将二者进行组合到另一个数组中即可方法1:常规思想,依次将奇数数据得到,进行重新组合到另一个数组中即可#include <stdio.h>#include <stdlib.h>void Printarr(int* arr,int size) { for (i原创 2020-09-28 21:46:39 · 344 阅读 · 0 评论 -
堆的模拟实现
堆的模拟实现//heap.p文件#pragma once #include <stdlib.h>#include <memory.h>typedef int HPDataType;typedef struct Heap{ HPDataType* _array; int _size; int _capacity;}Heap;void Swap(int array[], int left, int right);void shiftCreat(Heap*原创 2020-09-11 17:50:17 · 114 阅读 · 0 评论 -
队列和队列的模拟实现以及习题整理
队列实现队列满足先进先出的原则//quque.h文件#pragma once #include <stdlib.h>#include <stdio.h>typedef int QDataType;typedef struct QNode{ struct QNode* _next; QDataType _data;}QNode;typedef struct Queue{ QNode* _front; QNode* _rear; int _size;原创 2020-09-06 17:37:23 · 246 阅读 · 0 评论 -
链表的模拟实现以及重点习题整理
链表的实现://SingleList.c 文件#include "SingleList.h"#include <stdio.h>#include <string.h>#include <stdlib.h>void singleListInit(Singlelist* sl) { sl->_head = NULL;}Node* creatNode(Type data) { Node* node = (Node*)malloc(sizeof(No原创 2020-09-03 15:54:22 · 179 阅读 · 0 评论