Last active
May 27, 2018 20:21
-
-
Save thmain/8317c31bff7b1cfcda7f to your computer and use it in GitHub Desktop.
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
import java.util.*; | |
public class ConstructTriangle { | |
public void Triangle(int[] A) { | |
if (A.length >= 1) { | |
int[] temp = new int[A.length - 1]; | |
for (int i = 0; i < A.length - 1; i++) { | |
int x = A[i] + A[i + 1]; | |
temp[i] = x; | |
} | |
Triangle(temp); | |
System.out.println(Arrays.toString(A)); | |
} | |
} | |
public static void main(String[] args) { | |
int[] A = { 1, 2, 3, 4, 5 }; | |
ConstructTriangle c = new ConstructTriangle(); | |
c.Triangle(A); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment