高精度整数四维汇算(C++)

这是一个C++实现的高精度整数类,支持四则运算、比较操作及字符串转换。类中定义了bign类,包含构造函数、输入输出流重载以及加减乘除、比较和次方等方法。
摘要由CSDN通过智能技术生成

#include<string>  

#include<iostream>  

#include<iosfwd>  

#include<cmath>  

#include<cstring>  

#include<stdlib.h>  

#include<stdio.h>  

#include<cstring>  

#define MAX_L 999  

#define max(a,b) a>b ? a : b  

#define min(a,b) a<b ? a : b 

using namespace std;

class bign

{

public:

int len, s[MAX_L];//数的长度,记录数组  

  //构造函数  

bign();

bign(const char*);

bign(int);

bool sign;//符号 1正数 0负数  

string toStr() const;//转化为字符串,主要是便于输出  

friend istream& operator>>(istream &, bign &);//重载输入流  

friend ostream& operator<<(ostream &, bign &);//重载输出流  

  //重载复制  

bign operator=(const char*);

bign operator=(int);

bign operator=(const string);

//重载各种比较  

bool operator>(const bign &) const;

bool operator<(const bign &) const;

bool operator<=(const bign &) const;

//重载四则运算  

bign operator+(const bign &) const;

bign operator-(const bign &) const;

bign operator*(const bign &)const;

bign operator/(const bign&)const;

//四则运算的衍生运算

bign pow(const bign&)const;//次方

void clean();

};

bign::bign()

{

memset(s, 0, sizeof(s));

len = 1;

sign = 1;

}

<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值