Language/Algorithm28 Array Analyzer Example Input : 5 5 3 7 2 3 3 7 1 6 1 7 2 5 3 4 4 3 6 4 1 8 7 3 5 2 Output : 10 My answer: import java.util.Scanner; class ArrayAnalyzer { public static void main(String[] args) { ArrayAnalyzer t = new ArrayAnalyzer(); Scanner kb = new Scanner(System.in); int n = kb.nextInt(); int[][] a = new int[n+2][n+2]; for(int i = 1; i 2023. 12. 19. Matrix Max Sum Program Example Input : 5 10 13 10 12 15 12 39 30 23 11 11 25 50 53 15 19 27 29 37 27 19 13 30 13 19 Output : 155 My answer: import java.util.Scanner; class MatrixMaxSum { public static void main(String[] args) { MatrixMaxSum t = new MatrixMaxSum(); Scanner kb = new Scanner(System.in); int n = kb.nextInt(); int[][] a = new int[n][n]; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { a[i][j] = kb.. 2023. 12. 16. Element Ranking Code Example Input : 5 87 89 92 100 76 Output : 4 3 2 1 5 My answer: import java.util.Scanner; class ElementRanking { public static void main(String[] args) { ElementRanking t = new ElementRanking(); Scanner kb = new Scanner(System.in); int n = kb.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i++) { a[i] = kb.nextInt(); } for(int j : t.solution(n, a)) { System.out.print(j + " "); } } int[] s.. 2023. 12. 16. Count Consecutive 1s Total Example Input : 10 1 0 1 1 1 0 0 1 1 0 Output : 10 My answer : import java.util.*; class ConsecutiveOnesCounter { public static void main(String[] args) { ConsecutiveOnesCounter t = new ConsecutiveOnesCounter(); Scanner kb = new Scanner(System.in); int n = kb.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i++) { a[i] = kb.nextInt(); } System.out.println(t.solution(n, a)); } int solution(.. 2023. 12. 14. 이전 1 2 3 4 5 6 7 다음