class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
int[][] input = {{1, 3}, {7, -2, 0}, {4, 4}};
System.out.println(max(input));
int[] rowSumthing = allRowSums(input);
for (int element: rowSumthing)
{
System.out.print(element);
}
}
public static int max(int[][] a)
{
int max = a[0][0];
for (int i = 0; i<a.length; i++)
{
for (int j = 0; j<a[i].length; j++)
{
if (a[i][j]>max)
{
max = a[i][j];
}
}
}
return max;
}
// returns an array holding the sums of the rows in a
// e.g. allRowSums({{1}, {2, 3}, {4, 5, 6}}) = {1, 5, 15}
public static int[] allRowSums(int[][] a)
{
int[] rowSum = new int[a.length];
for (int i = 0; i<a.length; i++)
{
int rowTotal = 0;
for (int element:a[i])
{
rowTotal +=element;
}
rowSum[i] = rowTotal;
}
return rowSum;
}
}