乘积/乘法NSMutableArray值 [英] Product/Multiplication NSMutableArray Values
本文介绍了乘积/乘法NSMutableArray值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个NSMutableArray,我需要将其中所有数字的乘积制成。
我只是不知道该怎么做。
PS。我对Objective-C颇为陌生,因此请尽可能清楚。
谢谢
I have an NSMutableArray and I need to make the product of all the numbers inside it. I just can't understand how to do. PS. I'm quite new with objective-c so be as clear as possible. Thank's
推荐答案
是的,您也可以这样做。.
yes you can also do like this..
int result=1;
NSMutableArray *array=[[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4", nil];
for (int i=0; i<[array count]; i++) {
result*=[[array objectAtIndex:i] integerValue];
}
NSLog(@"%d ",result);
这篇关于乘积/乘法NSMutableArray值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文