Created
February 26, 2014 10:56
-
-
Save damirstuhec/9227519 to your computer and use it in GitHub Desktop.
Find the highest repeated character
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int array[255] = {0}; | |
NSString *test = @"Test string."; | |
int i = 0; | |
for(i = 0; i < test.length; i++) | |
{ | |
++array[[test characterAtIndex:i]]; | |
} | |
int max = array[0]; | |
int index = 0; | |
for(i = 0; i < 255; i++) | |
{ | |
if( array[i] > max) | |
{ | |
max = array[i]; | |
index = i; | |
} | |
} | |
NSLog(@"The highest repeated character is: %c", index); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment