about | help | code help+videos | done | prefs |
String lettersInOrder(String str) Return a string with str's characters in ASCII-alphabetical order, i.e. in order according to their values in the ASCII table. Don't forget about the spaces and punctuation! BIG HINT: You already know how to set up a count variable to keep track of the number of occurrences of a letter or pattern in a string as you loop through it. In this problem, you will create an int array of length 256, for all 256 ASCII values. Each member of this array represents a count variable keeping track of the number of occurrences of a specific character in the string. Think of the int array as containing 256 count variables, one for each ASCII character that may be present in str. The index of a member in this int array corresponds to the ASCII value of a character, e.g. the member at position 65 represents the number of occurrences of the capital letter A. You use "casts" to convert between characters and integers, e.g. (int)('A') is 65 and (char)(65) is 'A'. lettersInOrder("hello") → "ehllo" lettersInOrder("Zebediah") → "Zabdeehi" lettersInOrder("Chocolate Chip") → " CCacehhiloopt" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 21
Copyright Nick Parlante 2017 - privacy