/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
import java.util.Scanner;
public class Main
{
static int count = 0;
public static void main(String[] args) {
int[][] JaggedArray = new int[4][];
Scanner sc = new Scanner(System.in);
int[] input = new int[4];
System.out.println("Enter no. of slow learners in batch1");
input[0] = sc.nextInt();
System.out.println("Enter no. of slow learners in batch2");
input[1] = sc.nextInt();
System.out.println("Enter no. of slow learners in batch3");
input[2] = sc.nextInt();
System.out.println("Enter no. of slow learners in batch4");
input[3] = sc.nextInt();
System.out.println();
for(int y = 0; y < 4; y++)
{
JaggedArray[y] = Tutors(input[y]);
}
int jl = JaggedArray.length;
int jli = JaggedArray[0].length;
for(int w = 0; w < JaggedArray.length; w++)
{
for(int z = 0; z < JaggedArray[w].length; z++)
{
System.out.print(JaggedArray[w][z] + " ");
}
System.out.println();
}
System.out.println("No batches in which all tutors have exactly 4 students :" + count);
}
public static int[] Tutors(int a)
{
int l;
if(a % 4 == 0)
{
l = a / 4;
count++;
} else
{
l = (a / 4) + 1;
}
int[] b = new int[l];
for(int x = 0; x < l; x++)
{
if(a > 4)
{
b[x] = 4;
a -= 4;
}
else if(a < 4 && a != 0)
{
b[x] = a;
}
}
return b;
}
}