大数取余运算的C++实现

来源:百度知道 编辑:UC知道 时间:2024/05/31 13:38:09
用 std::string 存储的大数怎样进行取余运算?

int BigMod( string input )
{
... ...
... ...
// Could you please tell me the C++ implementation?
};

int main()
{
string a,b;
cin >> a >> b;
cout << a << " mod " << "b" << "is: " << BigMod( a , b ) << endl;

system("PAUSE");
return 0;
}

// Big_Int.cpp : Defines the entry point for the console application.
//
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
const long L = 900;
class Big_Int
{
public:
Big_Int();
~Big_Int();
Big_Int(const int ©);
Big_Int(const long ©);
Big_Int(const char *copy);
Big_Int &operator = (const Big_Int &right);
// "+":
Big_Int operator + (const Big_Int &second);
friend Big_Int operator + (const long &first, Big_Int &second);
friend Big_Int operator + (const char *first, Big_Int &second);
// "-":
Big_Int operator - (const Big_Int &second);
friend Big_Int operator - (const long &first, Big_Int &second);
friend Big_Int operator - (const char *first, Big_Int &second);
friend Big_Int operator - (const Big_Int &one);
// "*":
Big_Int operator * (const Big_Int &se