Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication6;
- /**
- *
- * @author Mihai
- */
- public class JavaApplication6 {
- public static void main(String[] args) {
- muestraResultado(tomaArray());
- }
- static int[] tomaArray() {
- int[] num = new int[]{2, 1, 2, 2, 2, 5, 5, 1, 2, 5};
- /*for (int i = 0; i < num.length; i++) {
- num[i] = (int) (Math.random() * 5);
- }*/
- return num;
- //return num;
- }
- /*
- * @param args the command line arguments
- */
- static void muestraResultado(int[] a) {
- int i, max = 1, parcial = 1;
- System.out.print("El array devuelto es: [");
- for (i = 0; i < a.length - 1; i++) {
- System.out.print(a[i] + ", ");
- if (a[i] == a[i + 1]) {
- parcial++;
- } else {
- parcial = 1;
- }
- if (parcial > max) {
- max = parcial;
- }
- }
- System.out.println(a[i] + "]");
- System.out.println("Tamaño de la repeticion mas larga es: " + max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement