Suppose you have a string Aabcad, write a program that removes the repeated characters from the string that are not contiguous. That is, after the string processing results are: AABCD;
Analysis, focusing on the implicit conversion of char and Int. The procedure is as follows:
-(void) Removerepeat: (NSString *) anum
{
Nsmutablearray *marr = [[Nsmutablearray alloc]initwithcapacity:10];
for (int i = 0; i<anum.length; i++)
{
[MArr addobject:[anum Substringwithrange:nsmakerange (i,1)];
}
NSLog (@ "%@", MARR);
[Self Comparenum:marr];
NSLog (@ "%@", MARR);
}
Comparison is equal
-(Nsmutablearray *) Comparenum: (Nsmutablearray *) MARR
{
int count = Marr.count; Redefined count does not decrease by 1
for (int j = 0; j< count-1; j + +)
{
for (int i = J;i < count-1-1-1;i++)
{
NSLog (@ "%@%@", [mArr Objectatindex:j],[marr objectatindex:i + 2]);
NSString *a = [MArr objectatindex:j];
NSString *b = [MArr objectatindex:i+2];
if ([a isequaltostring:b])
{
[MArr replaceobjectatindex:i + 2 withobject:@ "];
}
}
}
return MARR;
}
Go: Suppose you have a string Aabcad, write a program that removes the repeated characters from the string that are not contiguous.