高精度运算类 bign 和常用运算符重载
![](https://images0.cnblogs.com/blog2015/742134/201507/081537539396478.png)
#include <stdio.h> #include <string.h> #include <string> using std::string; const int maxn = 1000; struct bign { int len,s[maxn]; bign(){ memset(s, 0, sizeof(s));len =1;} //重新定义赋值运算符 bign operator =(const char* num) { len = strlen(num); for(int i =0;i<len;i++) s[i] = num[len-i-1]-'0'; return *this; } bign operator =(int num) { char s[maxn]; sprintf(s, "%d",num); *this =s; return *this; } bign (int num){ *this =num;} bign (const char* num){*this = num;} string str() const { string res = ""; for(int i =0;i<len;i++) res= (char)(s[i]+'0')+res; if(res == "") res ="0"; return res; } }; //重新定义》》和《《运算符 //重载bign的常用运算符 +-*/ 》 《 《= 》= != ==