hugeint.h

来自「此程序用于大整数运算」· C头文件 代码 · 共 65 行

H
65
字号
#ifndef HUGEINT
#define HUGEINT
#include <iostream>
#include <vector>
using std::ostream;
using std::vector;
using std::istream;
typedef vector<short> INT;
class HugeInt;										
HugeInt operator +(const HugeInt&,const HugeInt&);
HugeInt operator -(const HugeInt&,const HugeInt&);
HugeInt operator /(const HugeInt&,const HugeInt&);
HugeInt operator *(const HugeInt&,const HugeInt&);
HugeInt operator %(const HugeInt&,const HugeInt&);
bool operator >(const HugeInt&,const HugeInt&);
bool operator >=(const HugeInt&,const HugeInt&);
bool operator <(const HugeInt&,const HugeInt&);
bool operator <=(const HugeInt&,const HugeInt&);
bool operator ==(const HugeInt&,const HugeInt&);
bool operator !=(const HugeInt&,const HugeInt&);
istream& operator >>(istream&,HugeInt&);
ostream& operator <<(ostream&,HugeInt&);
bool compare(const INT&,const INT&);
INT operator +(const INT&,const INT&);
INT operator -(const INT&,const INT&);
INT operator /(const INT&,const INT&);
INT operator *(const INT&,const INT&);

struct math_error{
	int i;
	math_error(int ii){i=ii;}
	};
class HugeInt{
private:
	bool ch;
	INT value;
public:
	HugeInt();
	HugeInt(HugeInt &);
	HugeInt(long);
	HugeInt(char*);
	~HugeInt();
	HugeInt& operator =(const HugeInt&);

	friend HugeInt operator +(const HugeInt&,const HugeInt&);
	friend HugeInt operator -(const HugeInt&,const HugeInt&);
	friend HugeInt operator *(const HugeInt&,const HugeInt&);
	friend HugeInt operator /(const HugeInt&,const HugeInt&);
	friend HugeInt operator %(const HugeInt&,const HugeInt&);	
	friend bool operator >(const HugeInt&,const HugeInt&);
	friend bool operator >=(const HugeInt&,const HugeInt&);
	friend bool operator <(const HugeInt&,const HugeInt&);
	friend bool operator <=(const HugeInt&,const HugeInt&);
	friend bool operator ==(const HugeInt&,const HugeInt&);
	friend bool operator !=(const HugeInt&,const HugeInt&);
	friend istream& operator >>(istream&,HugeInt&);
	friend ostream& operator <<(ostream&,HugeInt&);
	friend bool compare(const INT&,const INT&);
	friend INT operator +(const INT&,const INT&);
	friend INT operator -(const INT&,const INT&);
	friend INT operator *(const INT&,const INT&);
	friend INT operator /(const INT&,const INT&);
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?