//
// main.m
// 第四题
//
// Created by ch on 15-3-31.
// Copyright (c) 2015年 ch. All rights reserved.
//
/*
4.实现函数:NSArray *kickOff10(NSArray *array);将数组中的@10去掉
*/
#import <Foundation/Foundation.h>
NSArray *kickOff10(NSArray *array);
int main()
{
NSArray *a1 = @[@"@10sdfg",@"sfhjdhg@10"];
NSArray *a2 = kickOff10(a1);
NSLog(@"%@",a2);
return 0;
}
NSArray *kickOff10(NSArray *array){
for(NSMutableString *str in array){
[array indexOfObject:str];
// NSMutableString *newstr = [NSMutableString stringWithString:str];
NSRange range = [str rangeOfString:@"@10"];
[str deleteCharactersInRange:range];
NSLog(@"%@",str);
//NSString *str = [NSString stringWithString:newstr];
}
NSArray *newarray = [NSArray arrayWithArray:array];
return newarray;
} |
|