Answers for "centered-15 java"

0

centered-15 java

public class iscentred15 {
    public static void main(String[] args) {
        int a[]={3, 2, 10, 4, 1, 6, 9};
        int result=f(a);
        System.out.println(result);
    } 
    private static int f(int[] a){
for (int i = 0; i <=(a.length / 2); i++) {
			int sum = 0;

			for (int j = i; j < (a.length - i); j++) {
				sum += a[j];
			}
			if (sum == 15)
				return 1;
		}
		return 0;    }
    
}
Posted by: Guest on May-29-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language