Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pruebas;
- /**
- *
- * @author Dell
- */
- public class Pruebas {
- public static int una=0,dos=0,tres=0,cuatro=0,cinco=0,seis=0,siete=0,ocho=0;
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- int array[]= {1,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0,0};
- int contador=0;
- int ayudante=0;
- int cambio = array[0];
- for (int i = 1; i < array.length; i++) {
- if(cambio != array[i]) {
- contador++;
- cambio = array[i];
- System.out.println(ayudante);
- ayuda(ayudante);
- ayudante=0;
- }
- else{
- ayudante++;
- }
- }
- System.out.println(una + " "+ dos + " "+ tres+" "+cuatro+ " "+ cinco +" "+seis+" "
- + siete+" "+ocho);
- }
- public static void ayuda(int ayudante){
- switch(ayudante){
- case 1:
- una++;
- break;
- case 2:
- dos++;
- break;
- case 3:
- tres++;
- break;
- case 4:
- cuatro++;
- break;
- case 5:
- cinco++;
- break;
- case 6:
- seis++;
- break;
- case 7:
- siete++;
- break;
- case 8:
- ocho++;
- break;
- default: ;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement