A=1,3,4,5,8,10,12,13,14,16,17,20,21,25,26,28 B=1,3,4,7,11,12,15,16,19,20,22,24,28,31,32 C=2,7,10,13,15,16,19,20,22,25,26,28,29,31,33 D=1,2,3,5,8,10,14,15,17,25,26,29,33 E=3,5,8,11,12,15,19,21,24,26,30,31,33 F=3,6,8,10,12,14,15,17,20,21,29,31 G=3,4,7,12,14,16,19,21,25,28,29,31 H=4,6,10,11,12,18,19,20,22,25,26,31 I=1,3,7,8,9,15,16,21,22,23,28,30,33 J=1,6,8,9,14,17,18,22,24,26,27,31,33 K=1,3,4,7,12,13,15,16,18,19,20,32,33
时间: 2023-09-19 22:11:51 浏览: 112
STC8A8K64S4A12国产单片机参考程序LCD12864 液晶oled LCD1602显示等45个例程工程源码.zip
5星 · 资源好评率100%
根据给定的多个不同长度的数组A到K,并找到与原始所有数组不重复的数字集合,可以按照以下步骤进行操作:
1. 创建一个空的哈希表,用于存储数字及其出现的次数。
2. 遍历所有的数组,对于每个数组中的每个数字,将其作为键值对应到哈希表中,并对应的值加1。
3. 再次遍历所有的数组,对于每个数组中的每个数字,检查它在哈希表中对应的值是否为1。如果是,则表示该数字只出现过一次,将其添加到结果集合中。
4. 返回结果集合即可得到与原始所有数组不重复的数字集合。
以下是基于给定数组A到K的示例代码:
```python
def find_unique_numbers(arrays):
hash_table = {}
result = set()
# 遍历所有数组,统计数字出现次数
for array in arrays:
for num in array:
if num in hash_table:
hash_table[num] += 1
else:
hash_table[num] = 1
# 再次遍历所有数组,找到不重复的数字
for array in arrays:
for num in array:
if hash_table[num] == 1:
result.add(num)
return result
# 给定数组A到K
A = [1,3,4,5,8,10,12,13,14,16,17,20,21,25,26,28]
B = [1,3,4,7,11,12,15,16,19,20,22,24,28,31,32]
C = [2,7,10,13,15,16,19,20,22,25,26,28,29,31,33]
D = [1,2,3,5,8,10,14,15,17,25,26,29,33]
E = [3,5,8,11,12,15,19,21,24,26,30,31,33]
F = [3,6,8,10,12,14,15,17,20,21,29,31]
G = [3,4,7,12,14,16,19,21,25,28,29,31]
H = [4,6,10,11,12,18,19,20,22,25,26,31]
I = [1,3,7,8,9,15,16,21,22,23,28,30,33]
J = [1,6,8,9,14,17,18,22,24,26,27,31,33]
K = [1,3,4,7,12,13,15,16,18,19,20]
arrays = [A,B,C,D,E,F,G,H,I,J,K]
unique_numbers = find_unique_numbers(arrays)
print(unique_numbers)
```
运行以上代码,将会输出与原始所有数组不重复的数字集合。
阅读全文