Skip to content

Instantly share code, notes, and snippets.

@ellbur
Created October 31, 2011 06:18
Show Gist options
  • Save ellbur/1327000 to your computer and use it in GitHub Desktop.
Save ellbur/1327000 to your computer and use it in GitHub Desktop.
Pairs
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