C:\Users\ar114\Documents\NetBeansProjects\Exam1_CalebFontenot\src\main\java\com\calebfontenot\exam1_calebfontenot\Question1.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.exam1_calebfontenot;
@author
public class Question1 {
public static void sort(int[] arr) {
for (int i = 0; i < arr.length - 1; ++i) {
for (int j = i + 1; j < arr.length; ++j) {
if (arr[i] > arr[j]) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
}
public static void print(int[][][] arr) {
for (int i = 0; i < arr.length; ++i) {
for (int j = 0; j < arr[i].length; ++j) {
for (int k = 0; k < arr[i][j].length; ++k) {
System.out.print(arr[i][j][k] + " ");
}
System.out.println();
}
}
}
public static void main(String[] args) {
int[][][] arr = {
{
{11, 2, 6, 22}, {3, 90, 112, 40, 7, 12}
},
{
{10, -20, 3}, {300, 50}
}
};
for (int i = 0; i < arr.length; ++i) {
for (int j = 0; j < arr[i].length; ++j) {
sort(arr[i][j]);
}
}
print(arr);
}
}