相关疑难解决方法(0)

如何在C++中添加2个任意大小的整数?

我想在C++中添加2个任意大小的整数.我该怎么做呢?

c++ bignum arbitrary-precision

8
推荐指数
3
解决办法
5851
查看次数

在C++中查找两个字符串是否为字谜

我正在尝试编写一个代码来检查字符串是否是一个字谜.但是我不断得到错误"你不能分配给一个恒定的变量".我理解这意味着什么,但是这个解决方法/解决方案是什么?

    #include <iostream>
    #include <algorithm>
    #include <string>
    using namespace std;

    bool check_str(const string& a, const string& b)
    {

    // cant be the same if the lenghts are not the same 
    if (a.length() != b.length())
        return false;
    //both the strings are sorted and then char by char compared
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    for (int i = 0; i < a.length(); i++)
    {
        if (a[i] != b[i]) //char by char comparison
            return false;
    }

    return true;
}

int main()
{
    string a …
Run Code Online (Sandbox Code Playgroud)

c++

-1
推荐指数
1
解决办法
245
查看次数

标签 统计

c++ ×2

arbitrary-precision ×1

bignum ×1