我正在嘗試顯示一個數組,其中包含數字(「prime」)的不同因子。但不是給我的int數,我總是得到0,1,2,3,4,5,...。在xcode中顯示數組
factors.text = @"";
int factorsNumber;
NSMutableArray *array;
array = [NSMutableArray arrayWithCapacity:5];
for (factorsNumber=1; factorsNumber<=prime; factorsNumber++) {
if (prime%factorsNumber == 0) {
[array addObject:[NSString stringWithFormat:@"%d", factorsNumber]];
}
}
for (int i = 0; i < [array count]; i++) {
[array replaceObjectAtIndex:1 withObject:@"4"];
NSString *temp = [NSString stringWithFormat:@"%d, ", i, [[array objectAtIndex:i] intValue]];
factors.text = [factors.text stringByAppendingString:temp];
}
什麼類型是'總理'? – Weston 2012-07-25 13:11:11
它是一個整數 – 2012-07-25 13:12:02