mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-16 20:42:00 -05:00
style:fmt
This commit is contained in:
@@ -3,23 +3,23 @@ package com.study.demo;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test3_3 {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] arr = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
arr[i] = scanner.nextInt();
|
||||
}
|
||||
int maxLen = 1, currentLen = 1;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (arr[i] == arr[i - 1]) {
|
||||
currentLen++;
|
||||
} else {
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
currentLen = 1;
|
||||
}
|
||||
}
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
System.out.println(maxLen);
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int n = scanner.nextInt();
|
||||
int[] arr = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
arr[i] = scanner.nextInt();
|
||||
}
|
||||
int maxLen = 1, currentLen = 1;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (arr[i] == arr[i - 1]) {
|
||||
currentLen++;
|
||||
} else {
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
currentLen = 1;
|
||||
}
|
||||
}
|
||||
maxLen = Math.max(maxLen, currentLen);
|
||||
System.out.println(maxLen);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user