【练习】BOOL类型 练习

#import

//returns NO if the two integers have the same

//value, YES therwise

BOOLareIntsDifferent (intthing1,intthing2)

{

    if(thing1 == thing2)

    {

        return(NO);

    }

    else{

        return(YES);

    }

} //areIntsDifferent

//given a NO valuem return the human-readable

//string "NO". Otherwise return "YES"

NSString*boolString (BOOLyesNO)

{

    if(yesNO ==NO)

    {

        return(@"NO");

    }

    else

    {

        return(@"YES");

    }

} //boolString

intmain(intargc,constchar* argv[]) {

    BOOLareTheyDifferent;

    areTheyDifferent =areIntsDifferent(5,5);

    NSLog(@"are %d and %d different? %@", 5,5, boolString(areTheyDifferent));

    areTheyDifferent =areIntsDifferent(23,42);

    NSLog(@"are %d and %d different? %@", 23,42, boolString(areTheyDifferent));

    return(0);

}

你可能感兴趣的:(【练习】BOOL类型 练习)