centered 15 java

Solutions on MaxInterview for centered 15 java by the best coders in the world

showing results for - "centered 15 java"
Maria José
29 Jun 2016
1public class iscentred15 {
2    public static void main(String[] args) {
3        int a[]={3, 2, 10, 4, 1, 6, 9};
4        int result=f(a);
5        System.out.println(result);
6    } 
7    private static int f(int[] a){
8for (int i = 0; i <=(a.length / 2); i++) {
9			int sum = 0;
10
11			for (int j = i; j < (a.length - i); j++) {
12				sum += a[j];
13			}
14			if (sum == 15)
15				return 1;
16		}
17		return 0;    }
18    
19}
20
queries leading to this page
centered 15 javacentered 15 java