Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- const int ksize = 1000;
- class Huge{
- public:
- int a[ksize];
- void Reset(){
- memset(a,0,sizeof(a));
- a[0]=1;
- }
- Huge(){
- Reset();
- }
- void setValue(int x){
- Reset();
- a[0]=0;
- do{
- a[0]++;
- a[a[0]] = x % 10;
- x/=10;
- }while(x);
- }
- void operator +=(const Huge &other){
- int i, t= 0;
- for(i = 1; i <= a[0] || i <= other.a[0] || t != 0;i++, t/=10)
- {
- a[i] = (t+= a[i] + other.a[i]) % 10;
- }
- a[0] = i - 1;
- }
- void addInteger(int x)
- {
- int i, t= 0;
- for(i = 1; i<= a[0] || x!=0 || t!= 0; i++, t/=10, x/=10)
- {
- a[i] = (t += a[i] + x % 10) % 10;
- }
- a[0] = i - 1;
- }
- void printNumber()
- {
- int i;
- for(i = a[0]; i >= 1; i--)
- printf("%d",a[i]);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement