开发者

predefined function for minimum [duplicate]

开发者 https://www.devze.com 2023-03-10 18:50 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Is there a convenient function in objective-c / coca-touch to find a lowest number?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

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;
}

I have to calculate the minimum value of two numbers. We can use if(a>b) to find out the minimum value.But is there 开发者_如何学Pythonany predefined function to calculate the minimum of two numbers.


There was already a discussion about this here. Objective-C includes a MIN(a,b) macro, which should suit your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号