セットコレクションを探索するためのPythonのアルゴリズムは兆候を見たようです

import ctypes,random


def setdata():
    lens=int.from_bytes(ctypes.string_at(id(set1)+32,8),byteorder='little')+1
    addr=int.from_bytes(ctypes.string_at(id(set1)+40,8),byteorder='little')
    l=[]
    for i in range(lens):
        if ctypes.string_at(addr+i*16,8)!=b'\x00\x00\x00\x00\x00\x00\x00\x00':
            l.append(str(int.from_bytes(ctypes.string_at(addr+i*16+8,8),byteorder='little')))
        else:l.append('__')
    print(' '.join(l))
    

set1=set()
t=ctypes.string_at(id(set1)+40,8)
id_=int.from_bytes(t,byteorder='little')
for i in [random.randint(0,100) for i in range(100)]:
    try:
        s=input('集合id:%s\t数据id:%s\t数值是:%s\t数字:指定数值,字符:跳出,回车:继续'%(id(set1),id_,i))
        ii=int(s)
    except:
        if s:break
    else:i=ii
    set1.add(i)
    #print(set1)
    setdata()
    if ctypes.string_at(id(set1)+40,8)!=t:
        print('数据区已转移,元素数%s'%len(set1))
        t=ctypes.string_at(id(set1)+40,8)
        id_=int.from_bytes(t,byteorder='little')
for i in set1:
    print(bin(i))

おすすめ

転載: blog.csdn.net/jhsxy2005/article/details/113957850