Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.