Skip to content

Instantly share code, notes, and snippets.

@StaniTr
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StaniTr/4eb5cc1718b73b6c398b to your computer and use it in GitHub Desktop.
Save StaniTr/4eb5cc1718b73b6c398b to your computer and use it in GitHub Desktop.
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Exam_Problem2_AddingAngles {
public static void main(String[] args) {
int count=0;
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine();
int[] nums = new int[n];
for (int i = 0; i < nums.length; i++) {
nums[i] = scanner.nextInt();
}
for (int x = 0; x < nums.length; x++) {
for (int y = x+1; y < nums.length; y++) {
for (int z = y+1; z < nums.length; z++) {
int checkSum=nums[x]+nums[y]+nums[z];
if (checkSum%360==0) {
System.out.println(nums[x]+" + "+nums[y]+" + "+nums[z]+" = "+checkSum+ " degrees");
count++;
}
}
}
}
//check if no
if (count==0) {
System.out.println("No");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment