Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args)
- {
- System.out.println(ContadorSecuencias(" ALALAFLEAsLA ALA como La jaja ALA"));
- }
- public static String ContadorSecuencias(String sCadena)
- {
- int index;
- int iContWord;
- int iContSec;
- boolean bSecExiste;
- iContWord = 0;
- iContSec = 0;
- bSecExiste = false;
- for (index = 0; index < sCadena.length(); index ++)
- {
- if (index == 0 && sCadena.charAt(index) == 'A')
- {
- while (index < sCadena.length() && sCadena.charAt(index) != ' ')
- {
- if (sCadena.charAt(index) == 'L' && sCadena.charAt(index + 1) == 'A')
- {
- iContSec ++;
- bSecExiste = true;
- }
- index ++;
- }
- if (bSecExiste = true) iContWord = 1; bSecExiste = false;
- }
- else
- {
- if (sCadena.charAt(index) == 'A' && sCadena.charAt(index - 1) == ' ')
- {
- while (index < sCadena.length() && sCadena.charAt(index) != ' ')
- {
- if (sCadena.charAt(index) == 'L' && sCadena.charAt(index + 1) == 'A')
- {
- iContSec ++;
- bSecExiste = true;
- }
- index ++;
- }
- if (bSecExiste = true) iContWord ++; bSecExiste = false;
- }
- }
- }
- return ("Existe " + iContWord + " palabra(s)\n") +
- ("Existe " + iContSec + " secuencia(s)");
- }
Advertisement
Add Comment
Please, Sign In to add comment