I am making a program that reads from a file and should find the five consecutive numbers with the biggest product. I thought I this would work but it doesn't, it doesn't generate but it just waits for input. Please don't ask what the problem is because the problem is that the program I thought should work doesn't! Thanks for the time:
No it is meant to not reset back to 0, its only suppose to do that once, then it will only change one value every time from then on! Study the code a bit more and you will understand but the answer I get is still wrong.
This is the first line the program is suppose to check:
73167176531330624919225119674426574742355349194934
This is how the array checks the numbers
7 * 3 * 1 * 6 * 7
[0] [1] [2] [3] [4]
then it changes the first in the array:
3 * 1 * 6 * 7 * 1
[1] [2] [3] [4] [0]
Notice how 0 now is the new number
1 * 6 * 7 * 1 * 7
[2] [3] [4] [0] [1]
Do you notice how I use the array? I am not very good with c++ but I thought this was a cool way.
6 * 7 * 1 * 7 * 6
[3] [4] [0] [1] [2]
every time the array changes the program evaluates the product and compares it to the biggest so far.
I solved the problem, the problem was that because char values isn't the same as the integer values the calculations was with the ascii codes making the answers really big numbers. I made a convertor though so now it works :)