/blog/images/avatar.webp

Hello World

Astyle 配置使用

Astyle 工具下载


Astyle 参数详解

括号类型

default brace style

默认采用大括号样式,开口大括号不变,闭合大括号将与上一行断开。

–style=allman / –style=bsd / –style=break / -A1

int Foo(bool isBar)
{
    if (isBar)
    {
        bar();
        return 1;
    }
    else
        return 0;
}

–style=java / –style=attach / -A2

int Foo(bool isBar) {
    if (isBar) {
        bar();
        return 1;
    } else
        return 0;
}

–style=kr / –style=k&r / –style=k/r / -A3

int Foo(bool isBar)
{
    if (isBar) {
        bar();
        return 1;
    } else
        return 0;
}

–style=stroustrup / -A4

int Foo(bool isBar)
{
    if (isBar) {
        bar();
        return 1;
    }
    else
        return 0;
}

在 Keil 中的使用


C++11 标准容器使用

容器的定义

在数据存储上,有一种对象类型,它可以持有其它对象或指向其它对像的指针,这种对象类型就叫做容器。


容器的分类

  1. 顺序容器

顺序容器是一种各元素之间有顺序关系的线性表,是一种线性结构的有序集合。这种顺序不依赖于元素的值,而是与元素加入容器的顺序相对应。顺序容器提供控制元素存储和访问顺序的能力。

力扣749. 隔离病毒

力扣749. Contain Virus(隔离病毒)

计算隔离病毒所需的最少防火墙数量。

示例 1:

../posts/01_学习/87_LeetCode/0749_隔离病毒/img/0749-1-description.png

输入:isInfected = [[0,1,0,0,0,0,0,1],[0,1,0,0,0,0,0,1],[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]]
输出:10
解释:...

提示:

  • m == isInfected.length, n == isInfected[i].length
  • 1 <= m, n <= 50
  • isInfected[i][j] 为 0 或 1

力扣743. 网络延迟时间

力扣743. Network Delay Time(网络延迟时间)

计算网络延迟时间。

示例 1:

../posts/01_学习/87_LeetCode/0743_网络延迟时间/img/0743-1-description.png

输入:times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
输出:2
解释:...

提示:

  • 1 <= k <= n <= 100
  • 1 <= times.length <= 6000
  • times[i] = [u, v, w], 1 <= w <= 100

力扣741. 摘樱桃

力扣741. Cherry Pickup(摘樱桃)

从左上到右下再返回能摘的最多樱桃。

示例 1:

../posts/01_学习/87_LeetCode/0741_摘樱桃/img/0741-1-description.png

输入:grid = [[0,1,-1],[1,0,-1],[1,1,1]]
输出:5
解释:...

提示:

  • n == grid.length
  • 1 <= n <= 50
  • grid[i][j] 为 -1、0 或 1

力扣737. 句子相似性 II

力扣737. Sentence Similarity II(句子相似性 II)

判断句子相似性(传递关系)。会员题。

示例 1:

../posts/01_学习/87_LeetCode/0737_句子相似性II/img/0737-1-description.png

输入:words1 = ["great","acting","skills"], words2 = ["fine","drama","talent"], pairs = [["great","good"],["fine","good"],["acting","drama"],["skills","talent"]]
输出:true
解释:...

提示:

力扣734. 句子相似性

力扣734. Sentence Similarity(句子相似性)

判断两个句子是否相似。会员题。

示例 1:

../posts/01_学习/87_LeetCode/0734_句子相似性/img/0734-1-description.png

输入:words1 = ["great","acting","skills"], words2 = ["fine","drama","talent"], pairs = [["great","fine"],["drama","acting"],["skills","talent"]]
输出:true
解释:...

提示: