I need help with arrays in C++. I am adding two large integers by inputing them as characters/ cstrings. But the carry...won't carry. My professor helped me a bit, but stopped part way to start lecture. can anyone help? http://codepad.org/q0VSwy6k http://codepad.org/CznCvpM8
i've just begun to look, but i don't understand the loop in reverseArray: CountA and CountB look like constants, independant of i.
countA and countB are local variables to the function ReverseArray. countA is 0 and countB is one less than the size of the array. I use the predefined function strlen to get the length of the cstring. Then, the for loop divided by two tells me how many times I'll execute the function call Swap. I swap the elements in the first and last indexes. Then I increment countA and decrement countB to swap the elements in those locations. I continue that process until the entire array is reversed.
well, if countA and countB are constant within the function call, and within the loop, why the loop? just swap(Array[0],Array[countB]) without out the loop which just repeats the same swap count/2 times (or swaps them back again, should counts be 4
i maybe missing it - late here, chicago - i'll wait to morning. good luck with it. countB is decrimented outside of the loop.
Yeah, I see what you're saying in regards to reverseArray. I've got it to work. If you have a compiler, here's the final program, that along with Hexadecimal. Hexadecimal(as its name implies) adds two numbers of base 16, whereas Big Integer adds two numbers of base 10. Big Integer (no clue why the output is whack): http://codepad.org/ggEbUyei Hexadecimal: http://codepad.org/fKhG09A0
Join our real-time social learning platform and learn together with your friends!