Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.  
  6.  
  7. public static void main(String[] args) {
  8. long begin = System.nanoTime();
  9. String str = "BABABABABA BAB BBAB ALA RURU YAYA PPUU IIFF";
  10. String vowels = "AEIOUYaeiouy";
  11. String unvowels = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxz";
  12. int counter = 0;
  13. for (int i = 0; i < str.length(); ++i) {
  14.  
  15. if (str.charAt(i) != ' ')
  16. {
  17.  
  18. int checkValue = 2;
  19. for (i = i; i<str.length() && str.charAt(i) != ' '; ++i) {
  20. if (checkValue != 3) {
  21. if (unvowels.indexOf(str.charAt(i))!=-1) {
  22. if (checkValue == 1) {
  23. checkValue = 3;
  24. } else
  25. checkValue = 1;
  26. }
  27. if (vowels.indexOf(str.charAt(i))!=-1) {
  28. if (checkValue == 0) {
  29. checkValue = 3;
  30. } else
  31. checkValue = 0;
  32. }
  33. }
  34. }
  35. if (checkValue == 1 || checkValue == 0) {
  36. counter++;
  37. }
  38. }
  39.  
  40. }
  41. System.out.println("zebroslov: "+counter);
  42. long elapsed = System.nanoTime() - begin;
  43. System.out.println(elapsed);
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement