【发布时间】:2011-09-10 00:04:12
【问题描述】:
可能重复:
Is there a convenient function in objective-c / coca-touch to find a lowest number?
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int a=10,b=5,c;
c=min(a,b);
NSLog(@"min:%d",c);
[pool drain];
return 0;
}
我必须计算两个数字的最小值。 我们可以使用 if(a>b) 来找出最小值。但是是否有任何预定义的函数来计算两个数字的最小值。
【问题讨论】:
-
还可以查看stackoverflow.com/questions/844990 并阅读有关
math.h的答案。
标签: objective-c