Created
October 31, 2011 06:18
-
-
Save ellbur/1327000 to your computer and use it in GitHub Desktop.
Pairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Pairs { | |
public static void main(String[] args) { | |
int[] cards = { 1, 2, 4, 1, 7 }; | |
boolean pair = false; | |
for (int i=0; i<cards.length; i++) { | |
for (int j=i+1; j<cards.length; j++) { | |
if (cards[i] == cards[j]) { | |
pair = true; | |
break; | |
} | |
} | |
} | |
if (pair) { | |
System.out.println("Pair"); | |
} | |
else { | |
System.out.println("No Pair"); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment