一个大数加法程序,本机测试正常,无法通过学校openjudge测评,还请各位帮忙分析

要求按照给出的main函数,编写一个类,处理大数与整数的加法;
以下是题目,源码在二楼贴出:

总时间限制:
1000ms
内存限制:
65536kB

描述

程序填空,输出指定结果

#include <iostream> 
#include <cstring> 
#include <cstdlib> 
#include <cstdio> 
using namespace std;
const int MAX = 110; 
class CHugeInt {

// 在此处补充你的代码

};
int  main() 
{ 
 char s[210];
 int n;

 while (cin >> s >> n) {
 CHugeInt a(s);
 CHugeInt b(n);

 cout << a + b << endl;
 cout << n + a << endl;
 cout << a + n << endl;
 b += n;
 cout  << ++ b << endl;
 cout << b++ << endl;
 cout << b << endl;
 }
 return 0;
}

输入
多组数据,每组数据是两个非负整数s和 n。s最多可能200位, n用int能表示
输出
对每组数据,输出6行,内容分别是:
样例输入

99999999999999999999999999888888888888888812345678901234567789 12
6 6

样例输出

99999999999999999999999999888888888888888812345678901234567801
99999999999999999999999999888888888888888812345678901234567801
99999999999999999999999999888888888888888812345678901234567801
25
25
26
12
12
12
13
13
14

#include
#include
#include
#include
using namespace std;
const int MAX = 110;
class CHugeInt {
private:
int val = 0;
char str[210];
int num[210];
int len;
public:
CHugeInt(){}
CHugeInt(int n)
{
val = n;
memset(str,0,210*sizeof(char));
memset(num,0,210*sizeof(int));
len = 0;
while(n != 0)
{
num[len] = n%10;
len ++;
n /= 10;
}
}

CHugeInt(const char * ch)
{
memset(num,0,210*sizeof(int));
memset(str,0,210*sizeof(char));
strcpy(str,ch);
len = strlen(str);
for(int i = 0; i < len; i ++)
num[i] = (int)(str[len-1-i] - 48);
}
~CHugeInt(){}
friend CHugeInt operator+(const CHugeInt & a,const CHugeInt & b) //MDZZ!!我自己都不知道是怎么编出来的...
{
CHugeInt oth;
int length = a.len;
length += 1; //考虑到进位情况
oth.len = length;
for(int k = 0; k < 210; k ++)
oth.num[k] = 0;
for( int i = 0; i < oth.len; i ++)
{
oth.num[i] += a.num[i] + b.num[i];
oth.num[i+1] += oth.num[i] / 10;
oth.num[i] = oth.num[i] % 10;
}
while((oth.len > 1) && (oth.num[oth.len-1] == 0))
oth.len --;
//神TM知道为什么要有下一步??!!
/* int k = 0;
for( int i = 0; i < oth.len; i ++)
oth.str[k ++] = (char)(oth.num[oth.len-1-i] + 48);
*/ return oth;
}

friend CHugeInt operator+(const int n,const CHugeInt & a) //为什么不能返回引用?
{
CHugeInt c;
int length = a.len;
length ++;
c.len = length;
int temp = n, i = 0;
for(int k = 0; k < 210; k ++)
c.num[k] = 0;
while(temp)
{
c.num[i] = temp%10;
i ++;
temp /= 10;
}
for(int j = 0; j < c.len; j ++)
{
c.num[j] += a.num[j];
c.num[j+1] += c.num[j] / 10;
c.num[j] = c.num[j] % 10;
}
while(c.len > 1 && c.num[c.len - 1] == 0) c.len --;
/* int k = 0;
for( int i = 0; i < c.len; i ++)
c.str[k ++] = (char)(c.num[c.len-1-i] + 48);
/ return c;
}
friend CHugeInt operator+(const CHugeInt &a, const int n)
{
CHugeInt c;
int length = a.len;
length ++;
c.len = length;
int temp = n, i = 0;
for(int k = 0; k < 210; k ++)
c.num[k] = 0;
while( temp)
{
c.num[i] += temp % 10;
i ++;
temp /= 10;
}
for(int j = 0; j < c.len; j ++)
{
c.num[j] += a.num[j];
c.num[j+1] += c.num[j] / 10;
c.num[j] = c.num[j] % 10;
}
while( c.len > 1 && c.num[c.len-1] == 0) c.len --;
/
int k = 0;
for( int i = 0; i < c.len; i ++)
c.str[i] = (char)( c.num[c.len-1-i] + 48);
*/ return c;
}

CHugeInt & operator+=(int n)
{
val += n;
return *this;
}
CHugeInt & operator++()
{
++val;
return *this;
}
CHugeInt operator++(int n) //此处一般不返回引用
{
CHugeInt ss = *this;
val ++;
return ss;
}

friend ostream & operator<<(ostream & out, const CHugeInt & c)
{
if(c.val == 0){
for( int i = c.len-1;i >= 0; i --)
out << c.num[i];
return out;}
else {
// cout << c.val;
out << c.val;
return out;}
}
};
int main()
{
char s[210];
int n;

while (cin >> s >> n) {
CHugeInt a(s);
CHugeInt b(n);

cout << a + b << endl;
cout << n + a << endl;
cout << a + n << endl;
b += n;
cout << ++ b << endl;
cout << b++ << endl;
cout << b << endl;
}
return 0;
}

oj程序不仅使用公开的测试用例,还会有别的测试用例,所以你应该全面检查你的程序