Files

32 lines
858 B
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 数字列表加法操作
## 需求
给定一个数字列表每个数字范围0-9
数字列表:
    数字189使用列表表示num1 = [1, 8, 9]
    数字21使用列表表示num2 = [2, 1]
    num1与num2相加结果 [2, 1, 0]
## 题目分析
在CC++等语言中,受限于计算机位数,整数最大值有限制;为了防止越界,导致计算结果错误,会使用巨型数组替代数字进行计算;
计算规则:
    1. 计算最低位,并检查是否有进位;
    2. 计算次低位,检查是否有进位;
    3. 如果两个数字列表长度不同,将为完成计算的插入到前面,并检查进位;
逻辑图如下:
<img src="file:///Users/wangyu/Library/Application%20Support/marktext/images/2026-01-08-17-08-29-image.png" title="" alt="" width="518">