Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

内存泄漏,申请的内存没有释放 #32

Open
csmasterpath opened this issue Aug 24, 2022 · 1 comment
Open

内存泄漏,申请的内存没有释放 #32

csmasterpath opened this issue Aug 24, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@csmasterpath
Copy link

int FindNoMin(int A[],int n)
{
    int *B,iB=(int*)malloc(sizeof(int)*n);//为数组申请内存空间
    for(i=0;i<n;i++)
        B[i]=0;//将数组初始化都为0
    for(i=0;i<n;i++)
        if(A[i]>0&&A[i]<=n)//若A属于0~n之间,标记B
            B[A[i]-1]=1;
    for(i=0;i<n;i++)//扫描计数数组,找到目标值
        if(B[i]==0)
            break;
    return i+1;
}
@xiaolei565 xiaolei565 added the bug Something isn't working label Aug 31, 2022
@xiaolei565
Copy link
Owner

是的,当时确实考虑不周,不过该代码不影响考试和解题思路,谢谢指正,我有空会更新文档的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants