I am doing a university project on a subject of algorithms and data structures in which I have to work with very large integers and perform operations with them. I have implemented the numbers as strings and then I have implemented the different functions for the operations. The problem is when the number of input data is too large that the application keeps running without giving any errors.
I have tried to understand the reason why this happens and I have made a small main in which I only take the big numbers as strings and store them in a dynamic array and then print them, but even that keeps running without stopping.
int main(int argc, const char * argv[]) {
int numOfNumbers;
int numbersAdded=0;
string input;
string * arrayStrings;
cin>>numOfNumbers;
arrayStrings = new string[numOfNumbers];
while(numbersAdded<numOfNumbers){
cin>>input;
arrayStrings[numbersAdded]=input;
numbersAdded++;
}
for( int i = 0;i<numOfNumbers;i++){
cout<<arrayStrings[i]<<endl;
}
delete arrayStrings;
return 0;
}
An example of an entry that gets you caught is:
100
1755128662250792726817307299021171022405
31602321932429919472347573932692115431
268613145625556
250995805115735123
2899821022216164821112051434821414118992115
27037278211962523201109134711837128617
279861141430143181518313
2556629007151952158131140
1196912232195651587224241
25217152742925013174325932918818704
127821054
253383867323001191423791
12348974130864
244901178019747324332994326262233310788
18871141121893613802910810566
298051220827966
22834322993767274181806121073176276959
12172351826990186206862376618791364
265732764173081220829716267442977319643273552225
24918204792116219043248262793915692401
1305831542
30700176671024343283713253592324315123
9631
1804116485164091127419645307015708
29922293842728930729216901755925702294991697
312452939618283102002333813782
97001726910215
23089
2228413461326671224530389
50281073851141324619663888524356
205537847
4387273422883676941299220683242529040
1068826033659423960273693499146131576
2353678092237010742
567428219113142508327393933916217
17519165136816290383310
171663253627992516622113674
13381174435173157252769015538248512802226982
18939548432449863556502935431668
227241606761772096923316172751849825321
28694
261158777214625061325511618639
26145245508605217823270225534
9144465612451
402063232412328332621313454157147811593510403
2974732438266188181
1971018749
2608143554273201627901930612227
167113264813914100695502
239491554826951684320992306102348527205832624426
322822701797512490321722
1222658617674291042489030110130720373
1918462976913296498889758915077263829448
272293167524341951427352662028327883857012375
174729150
1883623593305601460321897187512426209633019
8429505540641879120482112152815831074
2911590820561533087024079274326803
231262255129369314921398
30218
6853262887099
2979341273197322453071355192052510086228731082
6438195802600523532253931662830115
21455231162900119942
1839328344472262818266
2268711331105532851514258226702715029956686
1381271732204670982604920683
1750956011825180313080759535309
18306484
16752289242081714613984029594732346411804
269183243217101651922759
131903520
229283615302493931
25763
364627483502384441528056209239724
354632628
3536258474331130602772228026
287381151832596
28131307231326253372981510017858241118521
169071469721153
7226251212711565303162629173113572719
258312380924193826615620250272436820120
160731153614188
2355415899121291505218690251982485
2945329191793126217
199711279824919481281127503728828878916664
1846726425647269211818
2465830451616236642298932066180323217722337
2429926243493098211362313209
165211048224556263776021
7241210514
225393969266532086311050200721609924062
2391931833136282025125495
2211530320
15811209652225412597
104015738152769143240341892186871702212318
101430481142326694
327164589132301399725305
606829769525
136531485572681027581483494522825242