Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. package pruebas;
  2.  
  3. /**
  4. *
  5. * @author Dell
  6. */
  7. public class Pruebas {
  8. public static int una=0,dos=0,tres=0,cuatro=0,cinco=0,seis=0,siete=0,ocho=0;
  9. /**
  10. * @param args the command line arguments
  11. */
  12. public static void main(String[] args) {
  13. // TODO code application logic here
  14. int array[]= {1,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0,0};
  15. int contador=0;
  16. int ayudante=0;
  17.  
  18. int cambio = array[0];
  19.  
  20. for (int i = 1; i < array.length; i++) {
  21. if(cambio != array[i]) {
  22. contador++;
  23. cambio = array[i];
  24. System.out.println(ayudante);
  25. ayuda(ayudante);
  26. ayudante=0;
  27. }
  28. else{
  29. ayudante++;
  30.  
  31. }
  32.  
  33.  
  34.  
  35. }
  36. System.out.println(una + " "+ dos + " "+ tres+" "+cuatro+ " "+ cinco +" "+seis+" "
  37. + siete+" "+ocho);
  38.  
  39.  
  40. }
  41. public static void ayuda(int ayudante){
  42. switch(ayudante){
  43. case 1:
  44. una++;
  45. break;
  46. case 2:
  47. dos++;
  48. break;
  49. case 3:
  50. tres++;
  51. break;
  52. case 4:
  53. cuatro++;
  54. break;
  55. case 5:
  56. cinco++;
  57. break;
  58. case 6:
  59. seis++;
  60. break;
  61. case 7:
  62. siete++;
  63. break;
  64. case 8:
  65. ocho++;
  66. break;
  67. default: ;
  68. }
  69.  
  70. }
  71.  
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement