NSString *str= @"surname";
NSMutableString *consonants = [[NSMutableString alloc] init];
NSMutableString *vowels = [[NSMutableString alloc] init];
for (int i=0; i < [str length]; i++){
if ([str characterAtIndex:i] != 'a' && [str characterAtIndex:i] != 'e' && [str characterAtIndex:i] != 'i' && [str characterAtIndex:i] != 'o' && [str characterAtIndex:i] != 'u') {
[consonants appendFormat:@"%c",[str characterAtIndex:i]];
}
else{
[vowels appendFormat:@"%c",[str characterAtIndex:i]];
}
}
if([consonants length] < 3){
[consonants appendFormat:@"%@", [vocali characterAtIndex:1]];
}
我的问题是后续:
如果有较少的3辅音,我必须ñ元音附加到辅音串。追加字符串mutablestring
示例:
str =“mario”;
辅音=“mra”; // 2个辅音和1个元音
str = leo;
辅音=“leo”; // 1个辅音和2个元音
Thk。
我已经阅读并阅读你的问题,我只是不明白你想要 – Oliver