作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在处理 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/
我正在处理 vowel counting problem at coedabbey ,但我的解决方案似乎不起作用。这就是我正在做的事情: import java.util.Scanner; publi
int fnum = Integer.parseInt(split[0]);// holds 5 //split[] holds each line of the file. doub
我是一名优秀的程序员,十分优秀!