C++崩溃求调
查看原帖
C++崩溃求调
754040
yeqiwei楼主2024/8/6 18:03

rt,代码如下:

#include<bits/stdc++.h>
using namespace std;
void solve(int n)
{
    cout<<"2(";
    if(n==1)
    {
		cout<<"0)";
		return;
	}
    bool num[16];
    memset(num,false,sizeof(num));
    while(n)
    {
        int pos=floor(log2(n));
        n-=pow(pos,2);
        num[pos]=true;
    }
    int cnt=0;
    for(int i=0;i<16;++i)
    {
        if(num[i])
            solve(i);
        if(cnt++!=0)
            cout<<"+";
    }
    cout<<")";
}
int main()
{
    int n;
    cin>>n;
    solve(n);
    return 0;
}

在Dev-C++的调试功能中,代码运行到第15行 int pos=floor(log2(n)); 时出现崩溃,错误信息为:“cannot terminate an externally created thread”

2024/8/6 18:03
加载中...