Permalink
Browse files

Sum of Pairs: Java solution by Etienne Labuschagne

  • Loading branch information...
Andreas Pauley
Andreas Pauley committed Sep 17, 2009
1 parent 005aa44 commit 1722570f39c255f981ee2505f27edc19058c317f
Showing with 17 additions and 0 deletions.
  1. +17 −0 Snippets/SumPairs/SumOfNeighbours.java
@@ -0,0 +1,17 @@
+// Solution by Etienne Labuschagne
+
+public class SumOfNeighbours
+{
+ public static void main(String[] args)
+ {
+ int[] originalArray = new int[]{1,2,3,4,5};
+ int[] newArray = new int[4];
+
+ for (int i = 1; i < originalArray.length; i++)
+ newArray[i-1] = originalArray[i-1]+originalArray[i];
+
+
+ for (int i : newArray)
+ System.out.println(i);
+ }
+}

0 comments on commit 1722570

Please sign in to comment.