An Question waiting to solve(about uva424)

The following codes is the solving of uva424, but there are a some problems in these codes, who can help me to solve these annoy problem?
The codes wroten as follow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <iostream>
#include <cstring>
using std::istream;
using std::ostream;
using std::cin;
using std::cout;
using std::endl;
#define M 10100
#define N 10100   //10100
class bigInteger
{
private:
	char *Int;
public:
	bigInteger(char *num);
	bigInteger(char*num,int size);
	~bigInteger();
	void Insert(char num);
	bool operator !=( bigInteger &num);
	bigInteger & operator +=( bigInteger &num);
	friend istream & operator>>(istream &input, bigInteger &num);
	friend ostream & operator<<(ostream &output, bigInteger &num);
	friend void tranCtoN(char Int[]);
	friend void tranNtoC(char Int[]);
};

int main()
{
   // while(cin)
    {
        bigInteger sum("0",N);//累加和
        bigInteger end("0");//结束数据
        bigInteger num("\0",M);     //存放读入的大整数
        while(cin>>num && num!=end)
        {
            sum+=num;
        }
        cout<<sum<<endl;
    }
	return 0;
}
bigInteger::bigInteger(char *num)
{
	Int=new char [strlen(num)+1];
	strcpy(Int,num);
}
bigInteger::bigInteger(char *num,int size)
{
	int temp;
	temp=size>(strlen(num))?size:(strlen(num));
	Int=new char [temp+1];
	strcpy(Int,num);
}
bigInteger::~bigInteger()
{
	delete [] Int;
}
void tranCtoN(char Int[])
{
	int i;
	for(i=0;i<N && Int[i]!='\0';i++)
	{
		Int[i]=Int[i]-'0';
	}
}
void tranNtoC(char Int[])
{
	int i;
	for(i=0;i<N && Int[i]!='\0';i++)
	{
		if(Int[i]=='*')
		{
			Int[i]=Int[i]-'*'+'0';
		}
		else
		{
			Int[i]=Int[i]+'0';
		}
	}
}
void bigInteger:: Insert(char num)
{
	int i;
	for(i=0;Int[i]!='\0';i++);
	for(;i>=0;i--)
	{
		Int[i+1]=Int[i];
	}
	Int[i+1]=num;
}
bool bigInteger:: operator !=( bigInteger &num)
{
	int i;
	if(strlen(Int)!=strlen(num.Int))
	{
		return true;
	}
	else
	{
		for (i=0;Int[i]!='\0';i++)
		{
			if(Int[i]!=num.Int[i])
			{
				return true;
			}
		}
		return false;
	}
}
bigInteger & bigInteger:: operator +=(bigInteger &num)
{
	int i,j;
	int temp;
	i=strlen(Int);
	j=strlen(num.Int);
	temp=i>j?i:j;
	if(temp>i)
	{
		for(i;i<temp;i++)
		{
			Insert('0');
		}
	}
	else if(temp>j)
	{
		for(j;j<temp;j++)
		{
			num.Insert ('0');
		}
	}
	tranCtoN(Int);
	tranCtoN(num.Int);
	i=temp;
	i--;
	for(;i>=0;i--)
	{
		if(i==0)
		{
			if((num.Int[i]+Int[i])/10)
			{
				char tempchar=Int[i];
				Int[i]=(num.Int[i]+Int[i])%10;
				Insert((num.Int[i]+tempchar)/10);
			}
			else
			{
				Int[i]=(num.Int[i]+Int[i])%10;
			}
		}
		else
		{
			Int[i-1]=(num.Int[i]+Int[i])/10+Int[i-1];
			Int[i]=(num.Int[i]+Int[i])%10;
		}
		if(Int[i]=='\0')
		{
			Int[i]='*';
		}
	}
	tranNtoC(Int);
	return *this;
}
istream & operator>>(istream &input, bigInteger &num)
{
   char temp[1000];
   input >> temp;
   delete [] num.Int;
   num.Int = new char[strlen(temp)+1];
   strcpy(num.Int,temp);
   return input;
}
ostream & operator<<(ostream &output, bigInteger &num)
{
	output << num.Int;
    return output;
}

If you know those problems, whether you can solve it, please tell where are those problems!
P.S:uva 426 :http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=365
Last edited on


12
123
0
135
Press any key to continue

12
12
0
24
Press any key to continue


Wrong answer in the following input :

12
1
0
(There is a prompt displaying:After Normal block(#67) at 0x00550750)
Last edited on
Who the hell reported Softrix? His/her post was good advice, and was entirely reasonable.

Thanks for the backing MikeyBoy.

To be completely honest, although it is possible it wasn't the O/P that reported my post it has actually put me off from posting any further in this thread and offering my help.

His post was all left justified and very difficult to read and I simply asked for it to be edited inside code blocks so I could look at it better. Normally I would copy and paste into VS2013 which would do that for me, but at the time of my post I was not at the office and on my mobile.

Take care.

PS. I'm a he :)

You're welcome :)

I doubt it was the OP who reported you, since they did take your advice and edit their post to use code tags. I suspect there are others here with an axe to grind.
Or it was the OP and they just mixed up the Report and Reply buttons. It happens.

In the report button you give a reason though surely, or have to select something?

I did not know that. I thought it was just a button to alert a moderator to check out the post.

I just reported myself and pressed OK with no message to see what happens. Sorry Mods, please ignore the report. Just curious.
@ LB - thanks, I thought there would be something like that so whoever decided to report my post had obviously got some indication and it is therefore less likely a mistake. oh well :)
Topic archived. No new replies allowed.