Last active
August 29, 2015 14:24
-
-
Save josejaguirre/79dadea300535f4b210b to your computer and use it in GitHub Desktop.
This file contains 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
// Cadena original | |
NSString *cadena = @"El DevF rockea"; | |
// Cadena invertida | |
NSMutableString *reverse = [[NSMutableString alloc] init]; | |
int time = 0; | |
for (int i = (int)([cadena length] - 1); i >= 0; i--) { | |
NSRange subString = NSMakeRange(i, 1); | |
// Verifica si contiene la letra E o e en cadena | |
time += ([[cadena substringWithRange:subString] isEqual: @"e"] || [[cadena substringWithRange:subString] isEqual: @"E"] ) ? 1 : 0; | |
[reverse appendString:[cadena substringWithRange:subString]]; | |
} | |
NSLog(@"%@", reverse); | |
NSLog(@"%d veces", time); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment