hk wrote:There is only one interpretation possible:
Sum the following 100 numbers and give the ten most significant digits of the result.
If your program outputs a wrong result generate a smaller example and try to find out what the problem is(e.g. 10 9-digit numbers and compare the result with what you get using ordinary means).
We're not here to debug your program. That belongs to your ability to solve the problem.
(BTW the array length should be 100.)
The array length is 100 because the first entry starts at 0 and ends at 99. If you try and input array[100] in an array that was initialized with int array[] = new int[100]; then then it would error. (I realize that you most probably realize this.
I just tested my method with this array:
Code: Select all
String[] numbers = {
"123456789",
"312414321",
"125325234",
"321543232",
"124532234",
"123532423",
"124125134",
"124514232",
"321412323",
"314123231",
"343241232"
};
I summed this on my calculator, I got 2358220385 three times
I also summed the array by parsing all of those as double values, I got 2.358220385E9
My String summing method gives me 2358220385
stijn263 wrote:Just copy the values to excel and add 'm up. (you might need to use text to columns)
While a good Idea, I don't want to just get the answer. But currently I fear I am making an assumption and I have no idea where it is.
rayfil wrote:So you think I would include a leading zero? Honestly?
Believe me, that never even crossed my mind. Read my signature. Your assumption was absolutely WRONG, and taking such risks may alienate people who may be willing to help you.
I was only trying to help by asking a simple question, which you refused to answer. I will not make any attempt to assume the reason of your refusal; I would most probalby be wrong.
My objective wasn't to alienate you, but I am prone to taking things personally (the faceless nature of the internet doesn't help that fact), so I am sorry for snapping back at you.
But as for my interpretation of the leading zero, I would not enter a leading zero into the answer, and it is the result of my method. I fixed that problem but I still get the same answer numerically speaking. That zero, if it is a zero, is added only after it finishes everything else (Leading zeros won't show up any more).