Created
October 14, 2017 16:10
-
-
Save serhatsezer/43ada4ddd39eeda43527924d70c2c789 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static void main(String[] args) { | |
| System.out.println("Üçgen hesaplama: " + calculateTriangle(18)); | |
| } | |
| static String calculateTriangle(int sum) { | |
| int dividedAngle = sum % 3; | |
| int[] angles = {dividedAngle, dividedAngle, dividedAngle}; | |
| int previousAngle = 0; | |
| int[] matchedAngles = new int[2]; | |
| for(int i=0; i<angles.length; i++) { | |
| if(previousAngle == i) { | |
| matchedAngles[i] = i; | |
| } | |
| previousAngle = i; | |
| } | |
| if(matchedAngles.length == 2) { | |
| return "İkizkenar üçgen"; | |
| } | |
| if (sum % 3 == 0) { | |
| return "Eşkenar üçgen"; | |
| } | |
| return "Sıradan üçgen"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment