我有两个数组作为休闲,
NSArray *First=@[@"a", @"b", @"c",@"d", @"e", @"f",@"g", @"h", @"i", @"j", @"k"];
NSArray *Second=@[@"a",@"d", @"e",@"g",@"i"];
现在在
NSMutableArray *Result=[[NSMutableArray alloc]init];
当我的NSLog结果数组时,我将输出作为
[ b C F H Ĵ ķ ]
表示结果数组应该从第一个数组中删除第二个数组中的元素,条件是Witout usuing removeObjectAtIndex
方法
先谢谢。
答案 0 :(得分:2)
for (id object in First)
if (![Second containsObject:object]) [Result addObject:object];
答案 1 :(得分:2)
以下是获取输出的代码,无需使用removeObjectAtIndex Method.Try this:
NSArray *First=@[@"a", @"b", @"c",@"d", @"e", @"f",@"g", @"h", @"i", @"j", @"k"];
NSArray *Second=@[@"a",@"d", @"e",@"g",@"i"];
NSMutableArray *result=[[NSMutableArray alloc]init];
for (NSString *tempChar in First) {
if (![Second containsObject:tempChar]) {
[result addObject:tempChar];
NSLog(@"result arr :%@",result);
}
}
答案 2 :(得分:2)
var range = sheet.Cells["A3"].LoadFromText(new FileInfo(fileCSVFull), format, TableStyles.Medium27, true);
var numStyle = package.Workbook.Styles.CreateNamedStyle("TableNumber");
numStyle.Style.Numberformat.Format = "# ##0,00";
var tbl = sheet.Tables[0];
tbl.ShowTotal = true;
tbl.Columns[0].TotalsRowLabel = "Total";
tbl.Columns[1].TotalsRowFunction = RowFunctions.Sum;
tbl.Columns[1].DataCellStyleName = "TableNumber";
tbl.Columns[2].TotalsRowFunction = RowFunctions.Sum;
tbl.Columns[2].DataCellStyleName = "TableNumber";
tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum;
tbl.Columns[3].DataCellStyleName = "TableNumber";
string numcell = "E4:E"+(3 + nbline);
sheet.Cells[numcell].Formula = "B4*C4";
sheet.Cells[numcell].StyleName = "TableNumber";
sheet.View.ShowGridLines = false;
sheet.Calculate();
sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
答案 3 :(得分:1)
没有循环,您可以使用NSSet
NSMutableSet *firstSet1 = [NSMutableSet setWithArray: First];
NSSet *secondSet2 = [NSSet setWithArray: Second];
[firstSet1 minusSet: secondSet2];
NSArray * Result = [firstSet1 allObjects];