Results 1 to 3 of 3
Thread: Adding letters to arrays??
- 07-16-2010, 03:52 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 33
- Rep Power
- 0
Adding letters to arrays??
I am trying out these little crack the code programs and at one point there is a function that adds letter to the array then gets the modulo? i have no idea what it is doing.
the array is : "CQXVJBSNOONABXW"Java Code:char strarr[] = guess.toCharArray(); for (int i=0; i<strarr.length; i++) { strarr[i] = (char)((strarr[i]-'A'+9)%26+'A'); }
- 07-17-2010, 03:11 AM #2
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
ascii value of 'A'=65(decimal). 65+9=74.
so say the guess was 'a' which is equal to 97 in decimal. That would leave you
with 97-65+9=41.
41%26=15;
15+'A' = 15+ 65 = 80;
80 in ascii = P capital.
have a look here: Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion
- 07-19-2010, 01:37 AM #3
Similar Threads
-
Adding Arrays and Enhanced For Loop into program.
By vinyacam in forum New To JavaReplies: 1Last Post: 05-10-2010, 06:28 AM -
What does the letters mean?
By mustachMan in forum New To JavaReplies: 3Last Post: 02-11-2010, 09:50 PM -
Adding two Arrays
By Mayur in forum New To JavaReplies: 1Last Post: 09-26-2009, 11:49 PM -
Adding Values of 2 Arrays
By core2duo5252 in forum Java 2DReplies: 7Last Post: 09-05-2009, 03:50 AM -
need block letters??
By dc2acgsr99 in forum New To JavaReplies: 16Last Post: 01-29-2008, 08:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks