Skip to content

Instantly share code, notes, and snippets.

@thmain
Last active May 27, 2018 20:21
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 thmain/8317c31bff7b1cfcda7f to your computer and use it in GitHub Desktop.
Save thmain/8317c31bff7b1cfcda7f to your computer and use it in GitHub Desktop.
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