<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>C&#43;&#43; on My Blog</title>
    <link>http://localhost:1313/categories/c&#43;&#43;/</link>
    <description>Recent content from My Blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    
    <managingEditor>3453434429@qq.com (ArenBase)</managingEditor>
    <webMaster>3453434429@qq.com (ArenBase)</webMaster>
    
    <copyright>本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</copyright>
    
    <lastBuildDate>Fri, 10 Apr 2026 00:00:00 +0000</lastBuildDate>
    
    
    <atom:link href="http://localhost:1313/categories/c&#43;&#43;/index.xml" rel="self" type="application/rss&#43;xml" />
    

    
    

    <item>
      <title>常用的C&#43;&#43;头文件</title>
      <link>http://localhost:1313/post/%E5%B8%B8%E7%94%A8%E7%9A%84c&#43;&#43;%E5%A4%B4%E6%96%87%E4%BB%B6/</link>
      <pubDate>Fri, 10 Apr 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/%E5%B8%B8%E7%94%A8%E7%9A%84c&#43;&#43;%E5%A4%B4%E6%96%87%E4%BB%B6/</guid>
      <description>
        <![CDATA[<h1>常用的C++头文件</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <p>竞赛中，掌握常用算法头文件和相关方法能显著提升解题效率。以下是核心头文件及常用方法的总结：</p>
<h2 id="常用算法头文件">
<a class="header-anchor" href="#%e5%b8%b8%e7%94%a8%e7%ae%97%e6%b3%95%e5%a4%b4%e6%96%87%e4%bb%b6"></a>
常用算法头文件
</h2><p><strong>1. <code>&lt;algorithm&gt;</code>- 算法库核心</strong></p>
<ul>
<li>
<p><code>sort(begin, end, cmp)</code>- 排序（默认升序）</p>
        
        <hr><p>本文2026-04-10首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-04-10</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
    

    <item>
      <title>整数运算的类型与溢出防范</title>
      <link>http://localhost:1313/post/%E6%95%B4%E6%95%B0%E8%BF%90%E7%AE%97%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%BA%A2%E5%87%BA%E9%98%B2%E8%8C%83/</link>
      <pubDate>Sun, 05 Apr 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/%E6%95%B4%E6%95%B0%E8%BF%90%E7%AE%97%E7%9A%84%E7%B1%BB%E5%9E%8B%E4%B8%8E%E6%BA%A2%E5%87%BA%E9%98%B2%E8%8C%83/</guid>
      <description>
        <![CDATA[<h1>整数运算的类型与溢出防范</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h2 id="一表达式计算的基本规则">
<a class="header-anchor" href="#%e4%b8%80%e8%a1%a8%e8%be%be%e5%bc%8f%e8%ae%a1%e7%ae%97%e7%9a%84%e5%9f%ba%e6%9c%ac%e8%a7%84%e5%88%99"></a>
一、表达式计算的基本规则
</h2><h3 id="1-表达式的类型由操作数决定">
<a class="header-anchor" href="#1-%e8%a1%a8%e8%be%be%e5%bc%8f%e7%9a%84%e7%b1%bb%e5%9e%8b%e7%94%b1%e6%93%8d%e4%bd%9c%e6%95%b0%e5%86%b3%e5%ae%9a"></a>
1. 表达式的类型由操作数决定
</h3><p>在C++中，<strong>表达式的计算结果类型由==操作数的类型决定==，而不是由赋值目标的类型决定</strong>。</p>
        
        <hr><p>本文2026-04-05首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-04-05</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
    

    <item>
      <title>C&#43;&#43;循环条件中后置运算符的循环次数分析</title>
      <link>http://localhost:1313/post/c&#43;&#43;%E5%BE%AA%E7%8E%AF%E6%9D%A1%E4%BB%B6%E4%B8%AD%E5%90%8E%E7%BD%AE%E8%BF%90%E7%AE%97%E7%AC%A6%E7%9A%84%E5%BE%AA%E7%8E%AF%E6%AC%A1%E6%95%B0%E5%88%86%E6%9E%90/</link>
      <pubDate>Tue, 24 Mar 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/c&#43;&#43;%E5%BE%AA%E7%8E%AF%E6%9D%A1%E4%BB%B6%E4%B8%AD%E5%90%8E%E7%BD%AE%E8%BF%90%E7%AE%97%E7%AC%A6%E7%9A%84%E5%BE%AA%E7%8E%AF%E6%AC%A1%E6%95%B0%E5%88%86%E6%9E%90/</guid>
      <description>
        <![CDATA[<h1>C++循环条件中后置运算符的循环次数分析</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h2 id="一基本发现">
<a class="header-anchor" href="#%e4%b8%80%e5%9f%ba%e6%9c%ac%e5%8f%91%e7%8e%b0"></a>
一、基本发现
</h2><p>在C++的while循环中，使用后置递增(<code>n++</code>)或递减(<code>n--</code>)操作符时，循环次数与初始值有特定的数学关系：</p>
<table>
  <thead>
      <tr>
          <th>初始值</th>
          <th>循环条件</th>
          <th>循环次数</th>
          <th>是否有限</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>正数</td>
          <td><code>while(n--)</code></td>
          <td>n（初始值）</td>
          <td>是</td>
      </tr>
      <tr>
          <td>负数</td>
          <td><code>while(n++)</code></td>
          <td>n</td>
          <td>是</td>
      </tr>
      <tr>
          <td>非负数</td>
          <td><code>while(n++)</code></td>
          <td>无限（或直到溢出）</td>
          <td>否</td>
      </tr>
      <tr>
          <td>非正数</td>
          <td><code>while(n--)</code></td>
          <td>无限（或直到溢出）</td>
          <td>否</td>
      </tr>
  </tbody>
</table>
<h2 id="二底层原理">
<a class="header-anchor" href="#%e4%ba%8c%e5%ba%95%e5%b1%82%e5%8e%9f%e7%90%86"></a>
二、底层原理
</h2><h3 id="1-条件判断的隐式转换">
<a class="header-anchor" href="#1-%e6%9d%a1%e4%bb%b6%e5%88%a4%e6%96%ad%e7%9a%84%e9%9a%90%e5%bc%8f%e8%bd%ac%e6%8d%a2"></a>
1. 条件判断的隐式转换
</h3><p>C++中，所有条件表达式（if、while、for等）都会将结果隐式转换为<code>bool</code>类型：</p>
        
        <hr><p>本文2026-03-24首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-03-24</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
    

    <item>
      <title>哈希表unordered_map或者map查询规范</title>
      <link>http://localhost:1313/post/%E5%93%88%E5%B8%8C%E8%A1%A8unordered_map%E6%88%96%E8%80%85map%E6%9F%A5%E8%AF%A2%E8%A7%84%E8%8C%83/</link>
      <pubDate>Wed, 18 Mar 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/%E5%93%88%E5%B8%8C%E8%A1%A8unordered_map%E6%88%96%E8%80%85map%E6%9F%A5%E8%AF%A2%E8%A7%84%E8%8C%83/</guid>
      <description>
        <![CDATA[<h1>哈希表unordered_map或者map查询规范</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h2 id="总结优先使用方法1进行哈希表的查找">
<a class="header-anchor" href="#%e6%80%bb%e7%bb%93%e4%bc%98%e5%85%88%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%951%e8%bf%9b%e8%a1%8c%e5%93%88%e5%b8%8c%e8%a1%a8%e7%9a%84%e6%9f%a5%e6%89%be"></a>
总结：优先使用方法1进行哈希表的查找
</h2><h3 id="方法1">
<a class="header-anchor" href="#%e6%96%b9%e6%b3%951"></a>
方法1：
</h3><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">auto it = myMap.find(2); // 查找键为2的元素
</span></span><span class="line"><span class="cl">if (it != myMap.end()) {
</span></span><span class="line"><span class="cl">    std::cout &lt;&lt; &#34;Found: &#34; &lt;&lt; it-&gt;second &lt;&lt; std::endl;
</span></span><span class="line"><span class="cl">}
</span></span></code></pre></div><h4 id="原因">
<a class="header-anchor" href="#%e5%8e%9f%e5%9b%a0"></a>
原因：
</h4><p>使用<code>find()</code>函数，它执行纯查找操作，不修改容器。如果键不存在，返回<code>end()</code>迭代器，您可以安全地检查并处理未找到的情况，而不会影响<code>unordered_map</code>的状态。这是一种高效且无副作用的做法。</p>
        
        <hr><p>本文2026-03-18首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-03-18</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
    

    <item>
      <title>关switch语句中case语句后加不加大括号{}的风险</title>
      <link>http://localhost:1313/post/switch%E8%AF%AD%E5%8F%A5%E4%B8%ADcase%E8%AF%AD%E5%8F%A5%E5%90%8E%E5%8A%A0%E4%B8%8D%E5%8A%A0%E5%A4%A7%E6%8B%AC%E5%8F%B7%E7%9A%84%E9%A3%8E%E9%99%A9/</link>
      <pubDate>Wed, 18 Mar 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/switch%E8%AF%AD%E5%8F%A5%E4%B8%ADcase%E8%AF%AD%E5%8F%A5%E5%90%8E%E5%8A%A0%E4%B8%8D%E5%8A%A0%E5%A4%A7%E6%8B%AC%E5%8F%B7%E7%9A%84%E9%A3%8E%E9%99%A9/</guid>
      <description>
        <![CDATA[<h1>关switch语句中case语句后加不加大括号{}的风险</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h2 id="case的本质">
<a class="header-anchor" href="#case%e7%9a%84%e6%9c%ac%e8%b4%a8"></a>
case的本质：
</h2><p><code>case</code> 只是一个标签（label），并不会隐式创建新的作用域。（想象成一个不自动关门的“标记”）</p>
<p>如果你在一个 <code>case</code>的标记下面，直接写一句 <code>auto it = ...</code>或 <code>int x = 0</code>来声明并初始化一个变量，编译器就会报错（提示：“跨越初始化”）。它怕的是：如果程序执行时，从别的地方“跳”到了这个 <code>case</code>标记的下一行，那就跳过了你初始化变量的那一步。一个变量没初始化就被用，是很危险的，所以编译器干脆禁止你这么做。</p>
        
        <hr><p>本文2026-03-18首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-03-18</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
    

    <item>
      <title>Double类型浮点数偏差</title>
      <link>http://localhost:1313/post/double%E7%B1%BB%E5%9E%8B%E6%B5%AE%E7%82%B9%E6%95%B0%E5%81%8F%E5%B7%AE/</link>
      <pubDate>Sun, 22 Feb 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/double%E7%B1%BB%E5%9E%8B%E6%B5%AE%E7%82%B9%E6%95%B0%E5%81%8F%E5%B7%AE/</guid>
      <description>
        <![CDATA[<h1>Double类型浮点数偏差</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h1 id="1-核心矛盾有限的二进制位-vs-无限的实数">
<a class="header-anchor" href="#1-%e6%a0%b8%e5%bf%83%e7%9f%9b%e7%9b%be%e6%9c%89%e9%99%90%e7%9a%84%e4%ba%8c%e8%bf%9b%e5%88%b6%e4%bd%8d-vs-%e6%97%a0%e9%99%90%e7%9a%84%e5%ae%9e%e6%95%b0"></a>
1. 核心矛盾：有限的二进制位 vs 无限的实数
</h1><p>计算机内存是有限的，双精度浮点数（<code>double</code>）遵循IEEE 754标准，使用 <strong>64位</strong>​ 来存储一个数字。这64位被划分为符号位、指数位和尾数位（有效数字位）。关键限制在于：<strong>尾数部分只有53位有效二进制数字</strong>。</p>
        
        <hr><p>本文2026-02-22首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-02-22</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
  </channel>
</rss>
