我正在处理 vowel counting problem at coedabbey ,但我的解决方案似乎不起作用。这就是我正在做的事情:
import java.util.Scanner;
public class Solution {
private static Scanner input;
public static void main(final String[] args){
input = new Scanner(System.in);
int amount = input.nextInt();
for(int i = 0 ; i < amount ; i++){
int sum = 0;
String nowa = input.nextLine();
for(int j = 0; j < nowa.length() ; j++){
char x = nowa.charAt(j);
if(x == 'a' || x == 'o' || x == 'u' || x == 'i' || x == 'e' || x == 'y'){
++sum;
}
}
System.out.println(sum+ " ");
}
}
}
但它没有执行正确的行数,并且在我输入输入后始终输出 0
作为行计数。之后,它比我预期的少了一行。
示例运行可能如下所示:
> java Solution
> 3
0
> hello
2
> george
3
但是,我想输入另一行,因为我在开头说了“3”。
最佳答案
关于java - Codeabbey 中的元音计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30716272/