Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- long begin = System.nanoTime();
- String str = "BABABABABA BAB BBAB ALA RURU YAYA PPUU IIFF";
- String vowels = "AEIOUYaeiouy";
- String unvowels = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxz";
- int counter = 0;
- for (int i = 0; i < str.length(); ++i) {
- if (str.charAt(i) != ' ')
- {
- int checkValue = 2;
- for (i = i; i<str.length() && str.charAt(i) != ' '; ++i) {
- if (checkValue != 3) {
- if (unvowels.indexOf(str.charAt(i))!=-1) {
- if (checkValue == 1) {
- checkValue = 3;
- } else
- checkValue = 1;
- }
- if (vowels.indexOf(str.charAt(i))!=-1) {
- if (checkValue == 0) {
- checkValue = 3;
- } else
- checkValue = 0;
- }
- }
- }
- if (checkValue == 1 || checkValue == 0) {
- counter++;
- }
- }
- }
- System.out.println("zebroslov: "+counter);
- long elapsed = System.nanoTime() - begin;
- System.out.println(elapsed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement