⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 重载%.cpp

📁 巨型整数类
💻 CPP
字号:
#include"head.h"

HugeInt operator%(const HugeInt &a,const HugeInt &b){
	HugeInt h,h0,h1=a,h2=b;
	if(b==h) throw Modbyzero();
	h0=h1/h2;
	h=h1-h0*h2;
	return h;
}

//-------------------巨型整数%字符串------------------//
HugeInt operator%(const HugeInt &h,const char *buf){
	HugeInt h0,h1,h2;
    char str[MAX*Digit + 1];
    strcpy(str,buf);
	h1.str_to_huge(str,h1);
	if(h1==0L) throw Modbyzero(); //抛出除0异常
	return h2=h%h1;
}


//-----------------巨型整数%长整型-------------------//
HugeInt operator%(const HugeInt &h,const long &n){
	HugeInt h0,h1,h2;
	h1.long_to_huge(n,h1);
	if(h1==0L) throw Modbyzero();  //抛出除0异常
	return h2=h%h1;
}



//-------------------字符串%巨型整数--------------------------//
HugeInt operator%(const char *buf,const HugeInt &h){
	HugeInt h0,h1,h2;
	char str[MAX*Digit + 1];
	strcpy(str,buf);
	h1.str_to_huge(str,h1);  //字符串转化成巨型整数
	if(h==0L)  throw Modbyzero();  //抛出除0异常
	return h2=h1%h;
}

//-----------------长整型%字符串----------------------------//
HugeInt operator%(const long &n,const HugeInt &h){
	HugeInt h0,h1,h2;
	h1.long_to_huge(n,h1);
    if(h==0L)  throw Modbyzero();  //抛出除0异常
	return h2=h1%h;
}

//-----------------巨型整数%=巨型整数-----------------------//
HugeInt HugeInt::operator%=(const HugeInt &h){
	*this=*this%h;
	return *this;
}

⌨️ 快捷键说明

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