C++实现LeetCode(111.二叉树的最小深度)
[LeetCode] 111. Minimum Depth of Binary Tree 二叉树的最小深度Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shor...
[LeetCode] 111. Minimum Depth of Binary Tree 二叉树的最小深度Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shor...
1. 双缓冲机制所谓双缓冲机制,是指在绘制控件时,首先将要绘制的内容绘制在一个图片中,再将图片一次性地绘制到控件上。在早期的Qt版本中,若直接在控件上进行绘制工作,则在控件重...
[LeetCode] 107. Binary Tree Level Order Traversal II 二叉树层序遍历之二Given the root of a binary tree, return the bottom-up level order traversa...
[LeetCode] 108.Convert Sorted Array to Binary Search Tree 将有序数组转为二叉搜索树Given an array where elements are sorted in ascending order, convert it to a h...
来看看在windows操作系统下system () 函数详解(主要是在C语言中的应用)
注意:在windows下的system函数中命令可以不区别大小写!
函数名: system
功 能: 发出一个DOS命令
用 法...
在C语言中,想要获取字符串长度可以有很多方法,下面分别介绍一、使用sizeof()运算符在C语言中,sizeof() 是长度的运算符,括号中可以放入数据类型或者表达式,一般我们用来计算字符...
本文实例为大家分享了C语言版猜数字小游戏的具体代码,供大家参考,具体内容如下清楚实现目标做任何一个小项目之前,我们首先都需要明确自己想要实现的目标.所以猜数字游戏的实...
用C++的EasyX库做的拼图小游戏,供大家参考,具体内容如下  记录一下自己做的第一个项目,还有一些改进空间QWQ,可以支持难度升级,但是通关判断似乎有点小问题肯定不是...
前言网上有很多关于strtod()函数的文章,不过大部分都是用strtod()函数转换一个字符char *str = "111.11";char *target;double ret;ret = strtod(str, &target);很少有转换字...
[LeetCode] 110.Balanced Binary Tree 平衡二叉树Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined...
[LeetCode] 100. Same Tree 判断相同树Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if th...
这是一个用C语言实现的控制台小游戏—-五子棋,棋盘大小和获胜棋子数目是用宏定义的,可以自定义,所以可以轻松改为三子棋、六子棋等等。此游戏设定为人机对战(PVE),电脑走棋是随机...
[LeetCode] 130. Surrounded Regions 包围区域Given a 2D board containing 'X' and 'O'(the letter O), capture all regions surrounded by 'X'.A re...
[LeetCode] 120.Triangle 三角形Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For ex...
[LeetCode] 122.Best Time to Buy and Sell Stock II 买股票的最佳时间之二Say you have an array for which the ith element is the price of a given stock on...
简介本次五子棋使用的是光标控制移动,通过按空格键(键值32)来落子,实现游戏的。
我们额外用到的头文件有:#include<getch.h>
  通过调用getch()函数来识别 上下左右...
vector是一种动态数组,在内存中具有连续的存储空间,支持快速随机访问。由于具有连续的存储空间,所以在插入和删除操作方面,效率比较慢。vector有多个构造函数,默认的构造函数是构...
在C语言中,输入和输出除了用printf和scanf外,另外还有用于输入字符的函数为getchar()函数,用于输出字符的函数为putchar()函数。
功能解释如下:
下面用例子来说明函数的用法#inc...
[LeetCode] 128.Longest Consecutive Sequence 求最长连续序列Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your...
本文实例为大家分享了C语言实现简单贪吃蛇游戏的具体代码,供大家参考,具体内容如下用指针数组来表示蛇,p[0]表示蛇头控制方向:w,s,a,d-->上下左右 j,k-->加速、减速键盘控制需要...
方法一下面是输出当前目录下的所有文件夹以及文件的绝对路径(当然也可以是相对路径,由输入的路径决定),下面的函数接口可以改装为单输出文件或者文件夹的接口,这是一个大方面的总...
malloc的全称是memory allocation,中文叫动态内存分配,用于申请一块连续的指定大小的内存块区域以void*类型返回分配的内存区域地址,当无法知道内存具体位置的时候,想要绑定真正...
之前曾经使用过很多次c语言的命令行参数了,但是总是每次使用的时候都不太确定,需要重新查资料,这次来个总结。c语言的命令行参数非常简单,只需要一个简单的例子就可以说明:#...
Referencehttps://zhuanlan.zhihu.com/p/87864677步骤1、安装VSCode,直接在官网下载 安装即可
2、配置C/C++环境,安装MinGW编译器,也可以在 官网 下载安装
3、MinGW编译器刚才...
[LeetCode] 118.Pascal's Triangle 杨辉三角Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
In Pascal's trian...
[LeetCode] 123.Best Time to Buy and Sell Stock III 买股票的最佳时间之三Say you have an array for which the ith element is the price of a given stock o...
[LeetCode] 124. Binary Tree Maximum Path Sum 求二叉树的最大路径和Given a non-empty binary tree, find the maximum path sum.For this problem, a path is...
本文实例为大家分享了C语言实现贪吃蛇游戏的具体代码,供大家参考,具体内容如下在读大学生一枚,五一期间用四天时间写一个小游戏。本贪吃蛇游戏代码共计531行,开发环境是VS,游戏分...
目录传引用定义传引用与传值的区别传指针(地址)与传引用的区别总结传引用定义传值与传地址,相信大家都了如指掌了,在这里先介绍一下什么是引用?引用不是新定义一个变量,而是给已存...
[LeetCode] 126. Word Ladder II 词语阶梯之二Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation seq...
[LeetCode] 200. Number of Islands 岛屿的数量Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded...
验证LeetCode Surrounded Regions 包围区域的DFS方法在LeetCode中的Surrounded Regions 包围区域这道题中,我们发现用DFS方法中的最后一个条件必须是j > 1,如下面的红色字体所...
本文实例为大家分享了C语言实现图书馆管理系统的具体代码,供大家参考,具体内容如下全部代码如下:#include <stdio.h>#include<string.h>#include<stdlib.h>#include <mysql.h>#...
[LeetCode] 114. Flatten Binary Tree to Linked List 将二叉树展开成链表Given a binary tree, flatten it to a linked list in-place.For example,
Given1
/ \
2 &#...
[LeetCode] 116. Populating Next Right Pointers in Each Node 每个节点的右向指针You are given a perfect binary tree where all leaves are on the sam...
目录1. static_cast1.2 为什么要有static_cast等1.2 static_cast的作用1.3 static_cast用法2. dynamic_cast2.1 dynamic_cast 语法2.2 dynamic_cast 用法2.3 dynamic_cast...
目录可变参数
实现
代码
分析
关键语句
为什么
内存地址
难点
优化
总结可变参数
可变参数是指函数的参数的数据类型和数量都是不固定的。printf函数的参数就是可变的。这个...
[LeetCode] 119. Pascal's Triangle II 杨辉三角之二Given a non-negative index k where k ≤ 33, return the kth index row of...
目录1. 数组概述1.1 数组的定义1.2 数组的声明1.3 复合类型的数组1.4 数组的初始化规则1.5 C++11数组初始化方法2. 字符串2.1 C++处理字符串的两种方式:2.2 字符串常量的拼接...
目录1.什么是字节对齐
2.为什么要有字节对齐
3.手动设置对齐
4.结构体比较方法
1.什么是字节对齐
在c语言的结构体里面一般会按照某种规则去进行字节对齐。
我们先看一段代...
目录1. 左值和右值
2. 左值引用
3. 右值引用
3.1 出现
3.2 概念
3.3 应用
3.3.1 右值引用绑定到左值上
3.3.2 std::move()本质
3.3.3 移动构造函数和移动赋值运算符
3.3.4 s...
[LeetCode] 129. Sum Root to Leaf Numbers 求根到叶节点数字之和Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represe...
[LeetCode] 134.Gas Station 加油站问题There are N gas stations along a circular route, where the amount of gas at station i is gas[i].Yo...
本文实例为大家分享了C语言通讯录系统(增删改查),供大家参考,具体内容如下
全部代码如下所示:#include <iostream>#include <string>using namespace std;const int MAX = 1000;/...
[LeetCode] 115. Distinct Subsequences 不同的子序列Given a string S and a string T, count the number of distinct subsequences of S which...
[LeetCode] 117. Populating Next Right Pointers in Each Node II 每个节点的右向指针之二Given a binary treestruct Node {
int val;
Node *left;
Node *right;
Node *ne...
目录前言构造函数
通过构造函数实现的类型转换
派生类的构造函数
析构函数
继承中的析构函数
应用
总结前言我是练习时长一年的 C++ 个人练习生,喜欢野指针、模板报错和未定...
[LeetCode] 121.Best Time to Buy and Sell Stock 买卖股票的最佳时间Say you have an array for which the ith element is the price of a given stock on day&...
[LeetCode] 127.Word Ladder 词语阶梯Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation s...
目录1.迭代器
2.C++11 新增关键字auto
3.数组遍历法
4.基于范围的for循环
C++ vector遍历demo,多种姿势任你选~
1.迭代器
for(vector<int>::iterator it = obj.begin();...