【C++】递归填充矩阵的理论解析与实现

news/2024/12/15 4:57:54/
class="tags" href="/C.html" title=c>cle class="tags" href="/C.html" title=c>class="baidu_pl">
class="tags" href="/C.html" title=c>cle_class="tags" href="/C.html" title=c>content" class="tags" href="/C.html" title=c>class="articlass="tags" href="/C.html" title=c>cle_class="tags" href="/C.html" title=c>content class="tags" href="/C.html" title=c>clearfix">
class="tags" href="/C.html" title=c>content_views" class="tags" href="/C.html" title=c>class="markdown_views prism-tomorrow-night">class="tags" href="/C.html" title=c>cap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-bloclass="tags" href="/C.html" title=c>ck" style="-webkit-tap-highlight-class="tags" href="/C.html" title=c>color: rgba(0, 0, 0, 0);">

class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/class="tags" href="/C.html" title=c>cb7f73class="tags" href="/C.html" title=c>cda1a14130840e356class="tags" href="/C.html" title=c>cb0b6f9e4.png#piclass="tags" href="/C.html" title=c>c_class="tags" href="/C.html" title=c>center" alt="在这里插入图片描述" width="100" />

<class="tags" href="/C.html" title=c>center> 博客主页: [小ᶻ☡꙳ᵃⁱᵍᶜ꙳] class="tags" href="/C.html" title=c>center> <class="tags" href="/C.html" title=c>center> 本文专栏: C++ class="tags" href="/C.html" title=c>center>

class="tags" href="/C.html" title=c>class="toclass="tags" href="/C.html" title=c>c">

文章目录

  • 💯前言
  • 💯问题描述
  • 💯递归实现
  • 💯参数解析
    • 函数参数详解
    • 填充顺序分析
    • 递归终止条件
  • 💯示例解析
    • 第一层递归
    • 第二层递归
    • 第三层递归
    • 最终输出
  • 💯递归算法解析
    • 理论基础
    • 优点
    • 缺点
  • 💯优化与拓展
    • 1. 动态内存分配
    • 2. 非递归实现
    • 3. 拓展填充模式
  • 💯小结


class="tags" href="/C.html" title=c>c="https://img-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/00d4fdeb7b0d4dbb99e88f325ef249d8.gif#piclass="tags" href="/C.html" title=c>c_class="tags" href="/C.html" title=c>center" alt="在这里插入图片描述" width="1000" height="100" />


💯前言

  • C++ 编程领域class="tags" href="/C.html" title=c>c;<class="tags" href="/C.html" title=c>code>递归class="tags" href="/C.html" title=c>code> 是一种不可或缺的编程范式。它尤其适用于分层结构或<class="tags" href="/C.html" title=c>code>递归性质class="tags" href="/C.html" title=c>code>的问题࿰class="tags" href="/C.html" title=c>c;为解决复杂问题提供了优雅的框架。本文将全面剖析 递归填充矩阵问题class="tags" href="/C.html" title=c>c;深入探讨<class="tags" href="/C.html" title=c>code>代码实现class="tags" href="/C.html" title=c>code>、理论背景递归特性解析及其<class="tags" href="/C.html" title=c>code>优化与拓展class="tags" href="/C.html" title=c>code>。与此同时࿰class="tags" href="/C.html" title=c>c;还将对递归算法的核心思想进行更深层次的理论分析class="tags" href="/C.html" title=c>c;并提供实际应用中的<class="tags" href="/C.html" title=c>code>潜在扩展方案class="tags" href="/C.html" title=c>code>。
    C++ 参考手册
    class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/f0db7class="tags" href="/C.html" title=c>c348331440fa266b3class="tags" href="/C.html" title=c>c24f558694.png#piclass="tags" href="/C.html" title=c>c_class="tags" href="/C.html" title=c>center" alt="在这里插入图片描述" />

💯问题描述

构造一个矩阵࿰class="tags" href="/C.html" title=c>c;其中每一层以顺时针方向填充数字࿰class="tags" href="/C.html" title=c>c;从矩阵的外圈向内递归࿰class="tags" href="/C.html" title=c>c;直至整个矩阵被完整填充。这一问题表面看似简单࿰class="tags" href="/C.html" title=c>c;但其实隐藏了复杂的分层计算逻辑及递归思想的实践。

示例输入与输出

对于一个 5 × 5 的矩阵࿰class="tags" href="/C.html" title=c>c;按照递归方式填充后࿰class="tags" href="/C.html" title=c>c;结果如下:

<class="tags" href="/C.html" title=c>code>1   16   15   14   13
2   17   24   23   12
3   18   25   22   11
4   19   20   21   10
5    6    7    8    9
class="tags" href="/C.html" title=c>code>

外圈的数字从左上角按顺时针顺序递增࿰class="tags" href="/C.html" title=c>c;内圈依次类推࿰class="tags" href="/C.html" title=c>c;直到填充完毕。这种从外向内、逐层递归的填充方法展示了递归算法的分解和简化过程。本文将以递归方法实现这一填充方案࿰class="tags" href="/C.html" title=c>c;并进一步探讨其可能的扩展方式。


💯递归实现

以下为核心递归实现代码:
FillMatrix函数:

<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token keyword">void class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">FillMatrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int sizeclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int numclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 递归终止条件1:矩阵大小为0࿰class="tags" href="/C.html" title=c>c;返回class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(size class="tags" href="/C.html" title=c>class="token operator">== class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token keyword">returnclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 递归终止条件2:矩阵大小为1࿰class="tags" href="/C.html" title=c>c;填充中心点class="tags" href="/C.html" title=c>class="token keyword">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(size class="tags" href="/C.html" title=c>class="token operator">== class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= numclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">returnclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 填充外圈的四部分class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; iclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= num class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 左侧一列matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= num class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 底部一行matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1 class="tags" href="/C.html" title=c>class="token operator">- iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= num class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">2 class="tags" href="/C.html" title=c>class="token operator">* class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 右侧一列matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1 class="tags" href="/C.html" title=c>class="token operator">- iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= num class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">3 class="tags" href="/C.html" title=c>class="token operator">* class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 顶部一行class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 递归调用࿰class="tags" href="/C.html" title=c>c;进入内圈class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">FillMatrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">2class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, num class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">4 class="tags" href="/C.html" title=c>class="token operator">* class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, offset class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>code>

main函数:

<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token keyword">int class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">mainclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>const class="tags" href="/C.html" title=c>class="token keyword">int N class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">5class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 定义矩阵大小class="tags" href="/C.html" title=c>class="token keyword">int matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 初始化矩阵为全 0class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 调用递归函数填充矩阵class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">FillMatrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 打印矩阵class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; iclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int j class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; j class="tags" href="/C.html" title=c>class="token operator">< Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; jclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">setwclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token number">4class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator"><< matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[jclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>comment">// 格式化输出࿰class="tags" href="/C.html" title=c>c;确保对齐class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>cout class="tags" href="/C.html" title=c>class="token operator"><< endlclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token keyword">return class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>code>

class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/9b08class="tags" href="/C.html" title=c>ca1d82724class="tags" href="/C.html" title=c>c759class="tags" href="/C.html" title=c>c752d24class="tags" href="/C.html" title=c>c221class="tags" href="/C.html" title=c>cfd5.png#piclass="tags" href="/C.html" title=c>c_class="tags" href="/C.html" title=c>center" alt="在这里插入图片描述" />


💯参数解析


函数参数详解

  1. <class="tags" href="/C.html" title=c>code>int matrix[N][N]class="tags" href="/C.html" title=c>code>:目标矩阵࿰class="tags" href="/C.html" title=c>c;大小固定为 <class="tags" href="/C.html" title=c>code>N × Nclass="tags" href="/C.html" title=c>code>。
  2. <class="tags" href="/C.html" title=c>code>int sizeclass="tags" href="/C.html" title=c>code>:当前需要填充的子矩阵大小。
  3. <class="tags" href="/C.html" title=c>code>int numclass="tags" href="/C.html" title=c>code>:填充的起始数字。
  4. <class="tags" href="/C.html" title=c>code>int offsetclass="tags" href="/C.html" title=c>code>:当前子矩阵在整体矩阵中的偏移位置。

填充顺序分析

  1. 左侧一列:从顶部到底部依次填充:<class="tags" href="/C.html" title=c>code>matrix[offset + i][offset]class="tags" href="/C.html" title=c>code>。
  2. 底部一行:从左到右依次填充:<class="tags" href="/C.html" title=c>code>matrix[offset + size - 1][offset + i]class="tags" href="/C.html" title=c>code>。
  3. 右侧一列:从底部到顶部依次填充:<class="tags" href="/C.html" title=c>code>matrix[offset + size - 1 - i][offset + size - 1]class="tags" href="/C.html" title=c>code>。
  4. 顶部一行:从右到左依次填充:<class="tags" href="/C.html" title=c>code>matrix[offset][offset + size - 1 - i]class="tags" href="/C.html" title=c>code>。

递归终止条件

  • <class="tags" href="/C.html" title=c>code>size == 0class="tags" href="/C.html" title=c>code>:无需再填充࿰class="tags" href="/C.html" title=c>c;递归结束。
  • <class="tags" href="/C.html" title=c>code>size == 1class="tags" href="/C.html" title=c>code>:矩阵缩小至单个点࿰class="tags" href="/C.html" title=c>c;直接填充中心数字。

通过这样的顺序࿰class="tags" href="/C.html" title=c>c;我们可以层层缩小矩阵的计算范围࿰class="tags" href="/C.html" title=c>c;最终实现完整的矩阵填充。递归的设计核心在于其逻辑的分层性和简洁性࿰class="tags" href="/C.html" title=c>c;使得代码能够以最少的复杂度完成较为繁琐的操作。


💯示例解析

以下以 <class="tags" href="/C.html" title=c>code>FillMatrix(matrix, 5, 1, 0)class="tags" href="/C.html" title=c>code> 为例:


第一层递归

  1. <class="tags" href="/C.html" title=c>code>size = 5class="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;<class="tags" href="/C.html" title=c>code>offset = 0class="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;起始数字为 <class="tags" href="/C.html" title=c>code>1class="tags" href="/C.html" title=c>code>:
    • 左侧一列:1, 2, 3, 4, 5
    • 底部一行:6, 7, 8, 9
    • 右侧一列:10, 11, 12, 13
    • 顶部一行:14, 15, 16

第二层递归

  1. 调用 <class="tags" href="/C.html" title=c>code>FillMatrix(matrix, 3, 17, 1)class="tags" href="/C.html" title=c>code>:
    • 左侧一列:17, 18, 19
    • 底部一行:20, 21
    • 右侧一列:22, 23
    • 顶部一行:24

第三层递归

  1. 调用 <class="tags" href="/C.html" title=c>code>FillMatrix(matrix, 1, 25, 2)class="tags" href="/C.html" title=c>code>:
    • 中心点:25

最终输出

<class="tags" href="/C.html" title=c>code>1   16   15   14   13
2   17   24   23   12
3   18   25   22   11
4   19   20   21   10
5    6    7    8    9
class="tags" href="/C.html" title=c>code>

通过该示例࿰class="tags" href="/C.html" title=c>c;我们能够直观理解递归在每一步是如何逐步分解问题并完成填充的。


💯递归算法解析


理论基础

递归算法通过将问题分解为规模更小的子问题࿰class="tags" href="/C.html" title=c>c;从而达到解决整体问题的目的。其核心包括以下三要素:

  1. 递归终止条件:防止无限递归。
    • 在本例中࿰class="tags" href="/C.html" title=c>c;<class="tags" href="/C.html" title=c>code>size == 0class="tags" href="/C.html" title=c>code> 和 <class="tags" href="/C.html" title=c>code>size == 1class="tags" href="/C.html" title=c>code> 即为递归的终止条件。
  2. 递归子问题:将问题缩小为更简单的版本。
    • 在本例中࿰class="tags" href="/C.html" title=c>c;矩阵每次递归缩小外圈࿰class="tags" href="/C.html" title=c>c;最终进入中心点。
  3. 递归递推关系:问题规模如何递减࿰class="tags" href="/C.html" title=c>c;以及状态如何传递。
    • 本例中递归公式为:<class="tags" href="/C.html" title=c>code>FillMatrix(matrix, size - 2, num + 4 * (size - 1), offset + 1)class="tags" href="/C.html" title=c>code>。

递归算法之所以高效࿰class="tags" href="/C.html" title=c>c;是因为它能够自然地实现问题的分治思想࿰class="tags" href="/C.html" title=c>c;避免了手动控制循环的复杂性。尤其在分层结构中࿰class="tags" href="/C.html" title=c>c;递归能够显著减少代码冗余并提升逻辑的简洁性。


优点

递归实现能够以最少的代码完成复杂的分层逻辑࿰class="tags" href="/C.html" title=c>c;其结构直观࿰class="tags" href="/C.html" title=c>c;便于扩展。其应用场景广泛࿰class="tags" href="/C.html" title=c>c;从树形结构的遍历到动态规划中的状态转移࿰class="tags" href="/C.html" title=c>c;递归几乎无处不在。


缺点

递归可能因调用栈深度过大导致性能下降或栈溢出。在实际使用中࿰class="tags" href="/C.html" title=c>c;需要对递归深度进行评估࿰class="tags" href="/C.html" title=c>c;并通过优化递归设计来降低潜在风险。


💯优化与拓展


1. 动态内存分配

对于运行时动态确定矩阵大小的情况࿰class="tags" href="/C.html" title=c>c;可以采用如下动态分配方式:

<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token keyword">intclass="tags" href="/C.html" title=c>class="token operator">*class="tags" href="/C.html" title=c>class="token operator">* matrix class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token keyword">new class="tags" href="/C.html" title=c>class="token keyword">intclass="tags" href="/C.html" title=c>class="token operator">*class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; iclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token keyword">new class="tags" href="/C.html" title=c>class="token keyword">intclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
class="tags" href="/C.html" title=c>code>

这种方式能够显著提升程序的灵活性࿰class="tags" href="/C.html" title=c>c;使其能够适应更大规模的矩阵计算需求。


2. 非递归实现

递归可以转换为迭代算法以避免调用栈问题:

<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-class="tags" href="/C.html" title=c>cpp">class="tags" href="/C.html" title=c>class="token keyword">void class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">FillMatrixIterativeclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[Nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, class="tags" href="/C.html" title=c>class="token keyword">int nclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int num class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int offset class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; offset class="tags" href="/C.html" title=c>class="token operator">< class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(n class="tags" href="/C.html" title=c>class="token operator">+ class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token operator">/ class="tags" href="/C.html" title=c>class="token number">2class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; offsetclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>class="token keyword">int size class="tags" href="/C.html" title=c>class="token operator">= n class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">2 class="tags" href="/C.html" title=c>class="token operator">* offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token keyword">for class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>class="token keyword">int i class="tags" href="/C.html" title=c>class="token operator">= class="tags" href="/C.html" title=c>class="token number">0class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; i class="tags" href="/C.html" title=c>class="token operator">< size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; iclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= numclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= numclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1 class="tags" href="/C.html" title=c>class="token operator">- iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= numclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;matrixclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offsetclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">]class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">[offset class="tags" href="/C.html" title=c>class="token operator">+ size class="tags" href="/C.html" title=c>class="token operator">- class="tags" href="/C.html" title=c>class="token number">1 class="tags" href="/C.html" title=c>class="token operator">- iclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">] class="tags" href="/C.html" title=c>class="token operator">= numclass="tags" href="/C.html" title=c>class="token operator">++class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">}
class="tags" href="/C.html" title=c>code>

通过迭代方式实现矩阵填充࿰class="tags" href="/C.html" title=c>c;避免了递归可能导致的栈溢出问题࿰class="tags" href="/C.html" title=c>c;同时在某些场景下也能提升性能。


3. 拓展填充模式

除顺时针填充外࿰class="tags" href="/C.html" title=c>c;还可以实现:

  • 逆时针填充
  • 对角线填充
  • 双向递归:同时从外圈和内圈向中间填充࿰class="tags" href="/C.html" title=c>c;提升并行性。

通过拓展填充模式࿰class="tags" href="/C.html" title=c>c;可以满足不同的应用需求࿰class="tags" href="/C.html" title=c>c;例如图形处理、数据加密中的分层结构设计等。


💯小结

  • class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/4class="tags" href="/C.html" title=c>cf2beba4eclass="tags" href="/C.html" title=c>c24f6fbclass="tags" href="/C.html" title=c>cb17b5class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>c7609927.png#piclass="tags" href="/C.html" title=c>c_class="tags" href="/C.html" title=c>center" alt="在这里插入图片描述" />
    本文深入探讨了 递归填充矩阵 的<class="tags" href="/C.html" title=c>code>实现与理论背景class="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;并结合实例展示了递归在解决分层问题中的独特优势。尽管递归在解决复杂问题时表现出色࿰class="tags" href="/C.html" title=c>c;但需注意其<class="tags" href="/C.html" title=c>code>潜在的性能瓶颈class="tags" href="/C.html" title=c>code>与调用栈深度限制。在实际应用中࿰class="tags" href="/C.html" title=c>c;可根据具体需求选择递归或非递归实现。同时࿰class="tags" href="/C.html" title=c>c;通过<class="tags" href="/C.html" title=c>code>动态内存分配class="tags" href="/C.html" title=c>code>与模式拓展class="tags" href="/C.html" title=c>c;能够进一步提升算法的适用性。
    通过对本文内容的学习࿰class="tags" href="/C.html" title=c>c;希望读者能够更全面地理解 递归的本质 及其在实际问题中的应用潜力class="tags" href="/C.html" title=c>c;并能够在未来的实践中<class="tags" href="/C.html" title=c>code>灵活运用class="tags" href="/C.html" title=c>code>这些方法与思想来解决更复杂的工程问题

class="tags" href="/C.html" title=c>c="https://img-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/00d4fdeb7b0d4dbb99e88f325ef249d8.gif#piclass="tags" href="/C.html" title=c>c_class="tags" href="/C.html" title=c>center" alt="在这里插入图片描述" width="1000" height="100" />


class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/fclass="tags" href="/C.html" title=c>c6aclass="tags" href="/C.html" title=c>c6d93b4745b591bb8a8e48f86779.png#piclass="tags" href="/C.html" title=c>c_right" alt="在这里插入图片描述" width="1" />class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/fclass="tags" href="/C.html" title=c>c6aclass="tags" href="/C.html" title=c>c6d93b4745b591bb8a8e48f86779.png#piclass="tags" href="/C.html" title=c>c_right" alt="在这里插入图片描述" width="1" />class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/fclass="tags" href="/C.html" title=c>c6aclass="tags" href="/C.html" title=c>c6d93b4745b591bb8a8e48f86779.png#piclass="tags" href="/C.html" title=c>c_right" alt="在这里插入图片描述" width="1" />class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/fclass="tags" href="/C.html" title=c>c6aclass="tags" href="/C.html" title=c>c6d93b4745b591bb8a8e48f86779.png#piclass="tags" href="/C.html" title=c>c_right" alt="在这里插入图片描述" width="1" />class="tags" href="/C.html" title=c>c="https://i-blog.class="tags" href="/C.html" title=c>csdnimg.class="tags" href="/C.html" title=c>cn/direclass="tags" href="/C.html" title=c>ct/fclass="tags" href="/C.html" title=c>c6aclass="tags" href="/C.html" title=c>c6d93b4745b591bb8a8e48f86779.png#piclass="tags" href="/C.html" title=c>c_right" alt="在这里插入图片描述" width="1" />

class="tags" href="/C.html" title=c>class="blog-vote-box">

http://www.ppmy.cn/news/1555210.html

相关文章

爬虫获取的数据能否用于商业分析?

根据搜索结果&#xff0c;爬虫获取的数据能否用于商业分析&#xff0c;主要取决于以下几个因素&#xff1a; 数据的合法性与合规性&#xff1a; 爬虫技术本身并不违法&#xff0c;关键在于使用的方式和目的。爬虫技术的使用必须遵守相关法律法规&#xff0c;如《反不正当竞争法…

Flume 测试 Kafka 案例

Flume Kafka 测试案例&#xff0c;Flume 的配置。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 a1.sources s1 a1.channels c1 a1.sinks k1 a1.sources.s1.type netcat a1.sources.s1.bind master a1.sources.s1.port 44444 a1.channels.c1.type memory a1.sinks.k1.ty…

EasyGBS点对点穿透P2P远程访问技术在安防视频监控中的应用

随着信息技术的快速发展&#xff0c;安防视频监控系统在公共安全领域的应用变得越来越广泛。传统的视频监控系统多依赖于中心服务器进行视频流的集中处理和分发&#xff0c;这不仅增加了网络带宽的负担&#xff0c;还可能成为系统性能瓶颈。为了解决这些问题&#xff0c;P2P&am…

【前端 Uniapp】使用Vant打造Uniapp项目(避坑版)

一、基本介绍 Uniapp 是基于 Vue.js 的开发框架&#xff0c;通过一套代码可以同时发布到多个平台的应用框架。而 Vant 是针对移动端 Vue.js 的组件库。通过这样的组合&#xff0c;我们可以快速构建出一个跨平台的移动应用。Vant 已经支持多种小程序和 H5 平台&#xff0c;也对…

亚信安全DeepSecurity完成与超云超融合软件兼容性互认

近日&#xff0c;亚信安全与超云数字技术集团有限公司&#xff08;以下简称“超云”&#xff09;联合宣布&#xff0c;亚信安全成功完成与超云超融合软件的产品兼容性互认证。经严格测试&#xff0c;亚信安全云主机安全DeepSecurity与超云FS5000增强型融合系统&#xff08;简称…

Mybatis动态sql执行过程

动态SQL的执行原理主要涉及到在运行时根据条件动态地生成SQL语句&#xff0c;然后将其发送给数据库执行。以下是动态SQL执行原理的详细解释&#xff1a; 一、接收参数 动态SQL首先会根据用户的输入或系统的条件接收参数。这些参数可以是查询条件、更新数据等&#xff0c;它们…

调整Android导航栏(标题栏)的宽度高度

要调整导航栏&#xff08;标题栏&#xff09;的宽度&#xff0c;可以通过修改布局文件中的样式来实现。通常&#xff0c;标题栏是通过一个Toolbar或AppBarLayout来实现的。以下是一个示例&#xff0c;展示了如何调整标题栏的宽度和高度。 1. 修改布局文件 假设你的布局文件是…

【PyTorch】(基础五)---- 图像数据集加载

数据集 torchvision数据集 Torchvision在torchvision.datasets模块中提供了许多内置的数据集&#xff0c;以及用于构建您自己的数据集的实用程序类。关于一些内置数据集目录如下&#xff0c;点击进去之后会有详细的数据集介绍&#xff0c;包括数据集大小、分类类型、以及下载…