Skip to content

[1017 负二进制转换][C++] 调用allcase报错 #211

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

Closed
WangDongYao opened this issue Apr 6, 2023 · 1 comment · Fixed by #213
Closed

[1017 负二进制转换][C++] 调用allcase报错 #211

WangDongYao opened this issue Apr 6, 2023 · 1 comment · Fixed by #213

Comments

@WangDongYao
Copy link

/*
 * @lc app=leetcode.cn id=1017 lang=cpp
 * @lcpr version=
 *
 * [1017] 负二进制转换
 */

#include <array>
#include <bitset>
#include <climits>
#include <deque>
#include <functional>
#include <tuple>
#include <utility>
#include <list>
#include <forward_list>
#include <stack>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>

using namespace std;

// @lc code=start
class Solution
{
public:
    string baseNeg2(int n)
    {
        int val = 0x55555555 ^ (0x55555555 - n);
        if (val == 0)
            return "0";

        string res;
        while (val > 0)
        {
            res.push_back('0' + (val & 1));
            val >>= 1;
        }
        reverse(res.begin(), res.end());
        return res;
    }
};

// @lc code=end

/*
// @lcpr case=start
// 2\n
// @lcpr case=end

// @lcpr case=start
// 3\n
// @lcpr case=end

// @lcpr case=start
// 4\n
// @lcpr case=end

 */

报错信息如下图:
Xnip2023-04-06_18-50-27

@ccagml ccagml linked a pull request Apr 7, 2023 that will close this issue
@ccagml
Copy link
Owner

ccagml commented Apr 7, 2023

修复了,2.19.2,感谢

@ccagml ccagml closed this as completed Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants