主要主题是使用C ++编写带有链式哈希的代码(使用单个链接列表)。此处,数据是根据长数据类型的数组提供的,我们必须将其存储在哈希表中(表大小13)以一种排序的方式。
这是我的相同代码。 https://onlinegdb.com/B1pbgjxAI
代码中没有编译器错误,但是在运行代码时会出现以下错误。
*** buffer overflow detected ***: ./Solution terminated
Reading symbols from Solution...done.
[New LWP 86657]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./Solution'.
Program terminated with signal SIGABRT, Aborted.
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
To enable execution of this file add
add-auto-load-safe-path /usr/local/lib64/libstdc++.so.6.0.25-gdb.py
line to your configuration file "//.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "//.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
在这里,对于测试用例,输入为
201911169
,输出应为
93
答案 0 :(得分:1)
在第36行中,您正在调用strcpy(p->name,Name)
,但是Name
是从x
中的main
传递过来的,并且char x[4]
不是以空值结尾的您只能将x[j]
的{{1}}从2分配到0。添加一条语句j
。