+ 1
Java Weird Output
Hi! I am new to Java and am trying to go through a couple USACO problems, but I am getting weird output that I don't get in Python. In this program, I am trying to get the product of all the characters in a string (that I turned into a character array) where 1 represents "A", 2 represents "B", .... For some reason, when the groupnum variable should be equal to 17955, my program is outputting a random large negative number. I know that since the answer is under 2 billion, the problem is not that the result is too large for the int type. Thanks for your help! https://code.sololearn.com/cgSZlCFg9ZNE/#java
3 Antworten
+ 5
In the for-each loop, why you decrement <c> by 96? considering all capital letters, shouldn't it be c - 64?
+ 1
Wow that fixed it. Thank you so much! Ascii values have always been confusing for me.
+ 1
Glad it helps! 👌