verylong.h
来自「大数相乘的源代码,使用C++在VC环境中实现.」· C头文件 代码 · 共 37 行
H
37 行
//verylong.h
//class specifier for very long integer type
#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
const long int SZ=100000; //maximum digits in verylongs
class verylong
{
private:
char vlstr[SZ]; //verylong number,as a string
int vlen; //length of verylong string
verylong multdigit(const int)const;//prototypes for private functions
verylong mult10(const verylong)const;
public:
verylong():vlen(0) //no-arg constructor
{
vlstr[0]='\0';
}
verylong(const char s[SZ]) //one-arg constructor for string
{
strcpy(vlstr,s);
vlen=strlen(s);
}
verylong(const unsigned long n) //one-arg constructor for long int
{
ltoa(n,vlstr,10); //convert to string
strrev(vlstr); //reverse it
vlen=strlen(vlstr); //find length
}
void putvl() const; //display verylong
void getvl(); //get verylong from user
verylong operator +(const verylong); //add verylongs
verylong operator * (const verylong); //multiply verylongs
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?