【C++】1139:整理药名

server/2025/1/9 10:46:26/
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">

文章目录

  • 💯前言
  • 💯题目描述与需求分析
    • 题目描述
    • 输入格式
    • 输出格式
    • 输入输出样例
    • 需求分析
  • 💯我的解法与详细解析
    • 代码实现
    • 代码解析
    • 优点
    • 不足
  • 💯老师的解法与详细解析
    • 代码解析
    • 优点
    • 不足
  • 💯解法对比与优化建议
    • 相同点
    • 不同点
    • 优化建议
    • 优化后的代码
  • 💯知识点拓展
  • 💯小结


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>c;也是对代码逻辑、可读性和优化能力的一种考验。本文将以一个药品名称格式化的编程题为例࿰class="tags" href="/C.html" title=c>c;详细分析题目、两种不同的解法、它们的优缺点࿰class="tags" href="/C.html" title=c>c;并进行深入的优化与扩展探讨。
    我们将从以下几个方面展开:
    1. 题目描述与需求分析;
    2. 我的解法与详细解析;
    3. 老师的解法与详细解析;
    4. 两种解法的对比与优化建议;
    5. 对相关知识点的拓展。
      希望通过这篇文章࿰class="tags" href="/C.html" title=c>c;不仅帮助读者深入理解该问题的实现思路࿰class="tags" href="/C.html" title=c>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/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;具体如下:

题目描述

1139:整理药名
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/fe359ab23a3046de9b4e721aee29class="tags" href="/C.html" title=c>c5f4.png" 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>code>ASPIRINclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;规范化后为 <class="tags" href="/C.html" title=c>code>Aspirinclass="tags" href="/C.html" title=c>code>;
  • 输入 <class="tags" href="/C.html" title=c>code>aspirinclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;规范化后为 <class="tags" href="/C.html" title=c>code>Aspirinclass="tags" href="/C.html" title=c>code>;
  • 输入 <class="tags" href="/C.html" title=c>code>2-PENICILLINclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;规范化后为 <class="tags" href="/C.html" title=c>code>2-peniclass="tags" href="/C.html" title=c>cillinclass="tags" href="/C.html" title=c>code>。

输入格式

  1. 第一行一个整数 <class="tags" href="/C.html" title=c>code>nclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;表示有 <class="tags" href="/C.html" title=c>code>nclass="tags" href="/C.html" title=c>code> 个药品名称需要处理(<class="tags" href="/C.html" title=c>code>n \leq 100class="tags" href="/C.html" title=c>code>)。
  2. 接下来 <class="tags" href="/C.html" title=c>code>nclass="tags" href="/C.html" title=c>code> 行࿰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;长度不超过 20。

输出格式

  1. 输出 <class="tags" href="/C.html" title=c>code>nclass="tags" href="/C.html" title=c>code> 行࿰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-plaintext">4
Aspirin
class="tags" href="/C.html" title=c>cisapride
2-PENICILLIN
Cefradine-6
class="tags" href="/C.html" title=c>code>

输出样例:

<class="tags" href="/C.html" title=c>code class="tags" href="/C.html" title=c>class="prism language-plaintext">Aspirin
Cisapride
2-peniclass="tags" href="/C.html" title=c>cillin
Cefradine-6
class="tags" href="/C.html" title=c>code>

需求分析

  1. 首字母大写、其余小写的操作本质上是大小写转换问题࿰class="tags" href="/C.html" title=c>c;核心是理解字符的 ASCII 编码以及转换方法;
  2. 需要遍历字符串进行逐字符判断和转换;
  3. 考虑边界情况࿰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 maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><iostream>
class="tags" href="/C.html" title=c>class="token keyword">using class="tags" href="/C.html" title=c>class="token keyword">namespaclass="tags" href="/C.html" title=c>ce stdclass="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">25class="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>char class="tags" href="/C.html" title=c>chclass="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 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">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">;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>cin 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">;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">(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>cin class="tags" href="/C.html" title=c>class="token operator">>> class="tags" href="/C.html" title=c>chclass="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">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>chclass="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 operator">>= class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>char">'a' class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>chclass="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 operator"><= class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>char">'z'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>chclass="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 operator">-= class="tags" href="/C.html" title=c>class="token number">32class="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">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">while class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>chclass="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 operator">!= class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>char">'\0'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">if class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(class="tags" href="/C.html" title=c>chclass="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 operator">>= class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>char">'A' class="tags" href="/C.html" title=c>class="token operator">&& class="tags" href="/C.html" title=c>chclass="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 operator"><= class="tags" href="/C.html" title=c>class="token class="tags" href="/C.html" title=c>char">'Z'class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">)class="tags" href="/C.html" title=c>chclass="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 operator">+= class="tags" href="/C.html" title=c>class="token number">32class="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>ch 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/d3f1f8f436944e47ab0d2adb051f4e14.png" alt="在这里插入图片描述" />

代码解析

  1. 定义字符数组与常量:

    • 使用 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>char class="tags" href="/C.html" title=c>ch[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 = 25class="tags" href="/C.html" title=c>code> 确保数组容量足够(题目中药品名称长度上限为 20);
    • <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cin >> nclass="tags" href="/C.html" title=c>code> 读取药品名称的数量。
  2. 首字母处理:

    • 判断首字符是否为小写字母(<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>ch[0] >= 'a' && class="tags" href="/C.html" title=c>ch[0] <= 'z'class="tags" href="/C.html" title=c>code>)࿰class="tags" href="/C.html" title=c>c;如果是࿰class="tags" href="/C.html" title=c>c;则通过减去 32 转换为大写(利用 ASCII 编码:小写字母与对应大写字母的差值为 32)。
  3. 逐字符遍历:

    • 使用 <class="tags" href="/C.html" title=c>code>while (class="tags" href="/C.html" title=c>ch[j] != '\0')class="tags" href="/C.html" title=c>code> 遍历字符串中的其余字符࿰class="tags" href="/C.html" title=c>c;直到遇到字符串结束符 <class="tags" href="/C.html" title=c>code>\0class="tags" href="/C.html" title=c>code>;
    • 判断当前字符是否为大写字母(<class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>ch[j] >= 'A' && class="tags" href="/C.html" title=c>ch[j] <= 'Z'class="tags" href="/C.html" title=c>code>)࿰class="tags" href="/C.html" title=c>c;如果是࿰class="tags" href="/C.html" title=c>c;则通过加 32 转换为小写。
  4. 输出结果:

    • 每处理一个药品名称࿰class="tags" href="/C.html" title=c>c;直接输出结果。

优点

  • 逻辑简单清晰࿰class="tags" href="/C.html" title=c>c;直接基于 ASCII 编码进行大小写转换;
  • 使用基本循环结构࿰class="tags" href="/C.html" title=c>c;适合初学者学习与理解。

不足

  • 代码可读性不够高:直接操作 ASCII 值࿰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 maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><iostream>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>ctype>
class="tags" href="/C.html" title=c>class="token keyword">using class="tags" href="/C.html" title=c>class="token keyword">namespaclass="tags" href="/C.html" title=c>ce stdclass="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">25class="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>char arrclass="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 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">int n 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>cin 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">;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 funclass="tags" href="/C.html" title=c>ction">sclass="tags" href="/C.html" title=c>canfclass="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 string">"%s"class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">, arrclass="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">if 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 funclass="tags" href="/C.html" title=c>ction">islowerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 punclass="tags" href="/C.html" title=c>ctuation">)arrclass="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 operator">-= class="tags" href="/C.html" title=c>class="token number">32class="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">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">while class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 punclass="tags" href="/C.html" title=c>ctuation">{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">(class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">isupperclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 punclass="tags" href="/C.html" title=c>ctuation">)arrclass="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 operator">+= class="tags" href="/C.html" title=c>class="token number">32class="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"><< arr 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/04716fe55dd349728de50902class="tags" href="/C.html" title=c>c6b656d2.png" alt="在这里插入图片描述" />

代码解析

  1. 使用 <class="tags" href="/C.html" title=c>code><class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>ctype>class="tags" href="/C.html" title=c>code> 库函数:

    • <class="tags" href="/C.html" title=c>code>islower()class="tags" href="/C.html" title=c>code>:判断字符是否为小写字母;
    • <class="tags" href="/C.html" title=c>code>isupper()class="tags" href="/C.html" title=c>code>:判断字符是否为大写字母;
    • 这些库函数提高了代码可读性࿰class="tags" href="/C.html" title=c>c;避免了直接操作 ASCII 值。
  2. 输入输出:

    • 使用 <class="tags" href="/C.html" title=c>code>sclass="tags" href="/C.html" title=c>canf("%s", arr)class="tags" href="/C.html" title=c>code> 读取药品名称;
    • 使用 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>coutclass="tags" href="/C.html" title=c>code> 输出规范化结果。
  3. 逐字符遍历:

    • 首字符通过 <class="tags" href="/C.html" title=c>code>islower()class="tags" href="/C.html" title=c>code> 检查࿰class="tags" href="/C.html" title=c>c;若为小写则转换为大写;
    • 非首字符通过 <class="tags" href="/C.html" title=c>code>isupper()class="tags" href="/C.html" title=c>code> 检查࿰class="tags" href="/C.html" title=c>c;若为大写则转换为小写。

优点

  • 可读性高:借助 <class="tags" href="/C.html" title=c>code><class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>ctype>class="tags" href="/C.html" title=c>code> 库函数实现大小写判断࿰class="tags" href="/C.html" title=c>c;逻辑更加直观;
  • 代码结构清晰:将首字符和非首字符的处理逻辑分开。

不足

  • 混用了 <class="tags" href="/C.html" title=c>code>sclass="tags" href="/C.html" title=c>canfclass="tags" href="/C.html" title=c>code> 和 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>coutclass="tags" href="/C.html" title=c>code> 两种风格的输入输出࿰class="tags" href="/C.html" title=c>c;略显不统一;
  • 未处理输入字符串长度越界的情况。

💯解法对比与优化建议

相同点

  1. 两种解法的核心逻辑完全一致:
    • 首字母大写࿰class="tags" href="/C.html" title=c>c;其余字母小写;
    • 基于逐字符遍历实现。
  2. 都使用了字符数组存储字符串。

不同点

  1. 可读性:

    • 老师的代码通过 <class="tags" href="/C.html" title=c>code><class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>ctype>class="tags" href="/C.html" title=c>code> 库函数简化了大小写判断࿰class="tags" href="/C.html" title=c>c;逻辑更加直观;
    • 我的代码直接基于 ASCII 值࿰class="tags" href="/C.html" title=c>c;虽然实现简单࿰class="tags" href="/C.html" title=c>c;但可读性略差。
  2. 输入输出:

    • 老师的代码使用了 <class="tags" href="/C.html" title=c>code>sclass="tags" href="/C.html" title=c>canfclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;属于 C 风格输入;
    • 我的代码使用了 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;属于 C++ 风格输入。

优化建议

  1. 统一输入输出风格:

    • 统一使用 C++ 的 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>code> 和 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>coutclass="tags" href="/C.html" title=c>code>࿰class="tags" href="/C.html" title=c>c;符合现代编程习惯。
  2. 边界检查:

    • 对输入字符串长度进行限制࿰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>cin 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">(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">>> arrclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">;
      class="tags" href="/C.html" title=c>code>
  3. 避免全局变量:

    • 将字符数组定义为局部变量࿰class="tags" href="/C.html" title=c>c;减少作用域污染。
  4. 代码重构:

    • 使用 <class="tags" href="/C.html" title=c>code>toupper()class="tags" href="/C.html" title=c>code> 和 <class="tags" href="/C.html" title=c>code>tolower()class="tags" href="/C.html" title=c>code> 函数替代 ASCII 运算࿰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 maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><iostream>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>ctype>
class="tags" href="/C.html" title=c>class="token maclass="tags" href="/C.html" title=c>cro property">class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive-hash">#class="tags" href="/C.html" title=c>class="token direclass="tags" href="/C.html" title=c>ctive keyword">inclass="tags" href="/C.html" title=c>clude class="tags" href="/C.html" title=c>class="token string"><iomanip>
class="tags" href="/C.html" title=c>class="token keyword">using class="tags" href="/C.html" title=c>class="token keyword">namespaclass="tags" href="/C.html" title=c>ce stdclass="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">25class="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 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">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>cin 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">;class="tags" href="/C.html" title=c>class="token keyword">class="tags" href="/C.html" title=c>char arrclass="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">) class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">{class="tags" href="/C.html" title=c>cin 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">(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">>> arrclass="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">if 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 funclass="tags" href="/C.html" title=c>ction">islowerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 punclass="tags" href="/C.html" title=c>ctuation">)arrclass="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 operator">= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">toupperclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 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">1class="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">; arrclass="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">; 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>class="token keyword">if 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 funclass="tags" href="/C.html" title=c>ction">isupperclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 punclass="tags" href="/C.html" title=c>ctuation">)arrclass="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 operator">= class="tags" href="/C.html" title=c>class="token funclass="tags" href="/C.html" title=c>ction">tolowerclass="tags" href="/C.html" title=c>class="token punclass="tags" href="/C.html" title=c>ctuation">(arrclass="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 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"><< arr 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/7d2bclass="tags" href="/C.html" title=c>c55432fb490f9f4659231class="tags" href="/C.html" title=c>c5ba358.png" alt="在这里插入图片描述" />


💯知识点拓展

  1. 字符处理与 ASCII 编码:

    • 字符在计算机中以 ASCII 编码存储࿰class="tags" href="/C.html" title=c>c;大写字母和小写字母的差值为 32࿰class="tags" href="/C.html" title=c>c;这为大小写转换提供了简单的数学操作。
  2. <class="tags" href="/C.html" title=c>code><class="tags" href="/C.html" title=c>cclass="tags" href="/C.html" title=c>ctype>class="tags" href="/C.html" title=c>code> 库函数:

    • <class="tags" href="/C.html" title=c>code>islower()class="tags" href="/C.html" title=c>code>、<class="tags" href="/C.html" title=c>code>isupper()class="tags" href="/C.html" title=c>code>、<class="tags" href="/C.html" title=c>code>toupper()class="tags" href="/C.html" title=c>code>、<class="tags" href="/C.html" title=c>code>tolower()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>code>class="tags" href="/C.html" title=c>cinclass="tags" href="/C.html" title=c>code> 和 <class="tags" href="/C.html" title=c>code>class="tags" href="/C.html" title=c>coutclass="tags" href="/C.html" title=c>code> 是 C++ 的标准输入输出方式࿰class="tags" href="/C.html" title=c>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="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>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/server/156548.html

相关文章

Spring Boot 集成 MyBatis 全面讲解

Spring Boot 集成 MyBatis 全面讲解 MyBatis 是一款优秀的持久层框架&#xff0c;与 Spring Boot 集成后可以大大简化开发流程。本文将全面讲解如何在 Spring Boot 中集成 MyBatis&#xff0c;包括环境配置、基础操作、高级功能和最佳实践。 一、MyBatis 简介 1. SqlSession …

(六)优化 ChatGPT 交互:任务式 Prompt 的力量

&#x1f4e2;&#x1f4e2;&#x1f4e2; 大家好&#xff0c;我是云楼Yunlord&#xff0c;CSDN博客之星人工智能领域前三名&#xff0c;多年人工智能学习工作经验&#xff0c;一位兴趣稀奇古怪的【人工智能领域博主】&#xff01;&#xff01;&#xff01;&#x1f61c;&#…

深入理解非对称加密:用Java实现RSA加解密

目录 一、非对称加密算法概述 二、Java 中实现非对称加密 非对称加密&#xff08;Asymmetric Encryption&#xff09;是一种加密方式&#xff0c;其中使用一对密钥&#xff1a;公钥&#xff08;Public Key&#xff09;和私钥&#xff08;Private Key&#xff09;。这种加密算…

OpenGL —— 流媒体播放器 - ffmpeg解码rtsp流,opengl渲染yuv视频(附源码,glfw+glad)

效果 说明 FFMpeg和OpenGL作为两大技术巨头,分别在视频解码和图形渲染领域发挥着举足轻重的作用。本文将综合两者实战视频播放器,大概技术流程为:ffmpeg拉取rtsp协议视频流,并经过解码、尺寸格式转换为yuv420p后,使用opengl逐帧循环渲染该yuv实时视频。 核心源码 vertexSh…

Uniapp Android 本地离线打包(详细流程)

一、简介 App 离线 SDK 暂时不支持 Kotlin&#xff0c;未来不清楚。 uniapp 提供了 云打包 与 本地打包 两种方案&#xff0c;云打包 需要排队且还有次数限制&#xff0c;本地打包 则就没有这些限制&#xff0c;而且会 本地打包 对开发 原生插件 有很大的帮助。 细节&#x…

(安卓无线调试)ADB 无法连接及 Scrcpy 问题排查指南

问题描述 在使用 ADB 和 Scrcpy 时遇到以下问题&#xff1a; 无法连接到 ADB 服务。 即使连接成功&#xff0c;Scrcpy 显示以下错误&#xff1a; INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy> D:\.....\scrcpy\scrcpy-server.jar: 1 file pushed. 0.2 …

行为模式4.观察者模式------消息推送

行为型模式 模板方法模式&#xff08;Template Method Pattern&#xff09;命令模式&#xff08;Command Pattern&#xff09;迭代器模式&#xff08;Iterator Pattern&#xff09;观察者模式&#xff08;Observer Pattern&#xff09;中介者模式&#xff08;Mediator Pattern…

基于云架构Web端的工业MES系统:赋能制造业数字化变革

基于云架构Web端的工业MES系统:赋能制造业数字化变革 在当今数字化浪潮席卷全球的背景下,制造业作为国家经济发展的重要支柱产业,正面临着前所未有的机遇与挑战。市场需求的快速变化、客户个性化定制要求的日益提高以及全球竞争的愈发激烈,都促使制造企业必须寻求更加高效、智…