I'm trying to find the greatest integer of four integers and its ties. I used the following code. Is there anyway to simplify this?
int winner = MAX(self.playerOneScore, MAX(self.playerTwoScore, MAX(self.playerThreeScore, self.playerFourScore)));
if (winner == self.playerOneScore && winner != self.playerTwoScore && winner != self.playerThreeScore && winner != self.playerFourScore) {
NSLog(@"1");
} else if (winner == self.playerTwoScore && winner != self.playerOneScore && winner != self.playerThreeScore && winner != self.playerFourScore) {
NSLog(@"2");
} else if (winner == self.playerThreeScore && winner != self.playerOneScore && winner != self.playerTwoScore && winner != self.playerFourScore) {
NSLog(@"3");
} else if (winner == self.playerFourScore && winner != self.playerOneScore && winner != self.playerTwoScore && winner != self.playerThreeScore) {
NSLog(@"4");
} else if (self.playerOneScore == self.playerTwoScore || self.playerOneScore == self.playerThreeScore || self.playerOneScore == self.playerFourScore || self.playerTwoScore == self.playerThreeScore || self.playerTwoScore == self.playerFourScore || self.playerThreeScore == self.playerFourScore) {
NSLog(@"Tie");
}