C++ 添加自动加载安全路径黑客等级错误

C++ 添加自动加载安全路径黑客等级错误,c++,c,c++14,c++-standard-library,C++,C,C++14,C++ Standard Library,我需要找到数字的各个数字(并查看它是否是数字本身的除数),但行rem=n%10不可能,即操作/或%不可能。这是黑客级别 功能代码: int findDigits(int n) { int rem,count=0; int num=n; while(num > 0) { rem = num % 10; num =int ( num / 10); if( n % rem == 0) count++; } return count; } 错误: Program termin

我需要找到数字的各个数字(并查看它是否是数字本身的除数),但行
rem=n%10
不可能,即操作/或%不可能。这是黑客级别

功能代码:

    int findDigits(int n) 
{
int rem,count=0;
int num=n;
while(num > 0)
{
rem = num % 10;
num =int ( num / 10);

if( n % rem == 0) count++;
}
return count;
}
错误:

    Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x0000000000401417 in findDigits (n=<optimized out>) at Solution.cpp:24
24  if( num % rem == 0) count++;
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"
程序以信号SIGFPE终止,算术异常。
#0 0x0000000000401417,位于解决方案处的findDigits(n=)中。cpp:24
24如果(num%rem==0)计数++;
要启用此文件的执行,请添加
添加自动加载安全路径/usr/local/lib64/libstdc++.so.6.0.25-gdb.py
配置文件“/.gdbinit”的行。
要完全禁用此安全保护,请添加
设置自动加载安全路径/
配置文件“/.gdbinit”的行。
有关此安全保护的更多信息,请参阅
GDB手册中的“自动加载安全路径”部分。例如,从外壳运行:
信息“(gdb)自动加载安全路径”

这只是因为rem=0的情况

天哪,你把事情复杂化了!同时用C、C++14和C++17编写一个程序太过分了!关于这个bug,当
num
是10的倍数时,想想
rem
的值。@user4581301哦,你说得对,非常感谢。真不敢相信我错过了xD