<small id='uHOU9'></small><noframes id='uHOU9'>

    <i id='uHOU9'><tr id='uHOU9'><dt id='uHOU9'><q id='uHOU9'><span id='uHOU9'><b id='uHOU9'><form id='uHOU9'><ins id='uHOU9'></ins><ul id='uHOU9'></ul><sub id='uHOU9'></sub></form><legend id='uHOU9'></legend><bdo id='uHOU9'><pre id='uHOU9'><center id='uHOU9'></center></pre></bdo></b><th id='uHOU9'></th></span></q></dt></tr></i><div id='uHOU9'><tfoot id='uHOU9'></tfoot><dl id='uHOU9'><fieldset id='uHOU9'></fieldset></dl></div>

      • <bdo id='uHOU9'></bdo><ul id='uHOU9'></ul>
      <legend id='uHOU9'><style id='uHOU9'><dir id='uHOU9'><q id='uHOU9'></q></dir></style></legend>
      1. <tfoot id='uHOU9'></tfoot>

        如何检查字符是否为元音?

        时间:2023-07-28
      2. <i id='xYQnR'><tr id='xYQnR'><dt id='xYQnR'><q id='xYQnR'><span id='xYQnR'><b id='xYQnR'><form id='xYQnR'><ins id='xYQnR'></ins><ul id='xYQnR'></ul><sub id='xYQnR'></sub></form><legend id='xYQnR'></legend><bdo id='xYQnR'><pre id='xYQnR'><center id='xYQnR'></center></pre></bdo></b><th id='xYQnR'></th></span></q></dt></tr></i><div id='xYQnR'><tfoot id='xYQnR'></tfoot><dl id='xYQnR'><fieldset id='xYQnR'></fieldset></dl></div>
      3. <small id='xYQnR'></small><noframes id='xYQnR'>

          <tbody id='xYQnR'></tbody>

            <bdo id='xYQnR'></bdo><ul id='xYQnR'></ul>

                  <tfoot id='xYQnR'></tfoot>
                • <legend id='xYQnR'><style id='xYQnR'><dir id='xYQnR'><q id='xYQnR'></q></dir></style></legend>
                  本文介绍了如何检查字符是否为元音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这段 Java 代码给我带来了麻烦:

                  This Java code is giving me trouble:

                      String word = <Uses an input>
                      int y = 3;
                      char z;
                      do {
                          z = word.charAt(y);
                           if (z!='a' || z!='e' || z!='i' || z!='o' || z!='u')) {
                              for (int i = 0; i==y; i++) {
                                  wordT  = wordT + word.charAt(i);
                                  } break;
                           }
                      } while(true);
                  

                  我想检查单词的第三个字母是否是非元音,如果是,我希望它返回非元音及其前面的任何字符.如果是元音,则检查字符串中的下一个字母,如果也是元音,则检查下一个字母,直到找到非元音为止.

                  I want to check if the third letter of word is a non-vowel, and if it is I want it to return the non-vowel and any characters preceding it. If it is a vowel, it checks the next letter in the string, if it's also a vowel then it checks the next one until it finds a non-vowel.

                  例子:

                  word = Jaemeas 然后 wordT 必须 = Jaem

                  word = Jaemeas then wordT must = Jaem

                  示例 2:

                  word=Jaeoimus 然后 wordT 必须 =Jaeoim

                  word=Jaeoimus then wordT must =Jaeoim

                  问题在于我的 if 语句,我不知道如何让它检查那一行中的所有元音.

                  The problem is with my if statement, I can't figure out how to make it check all the vowels in that one line.

                  推荐答案

                  你的情况有问题.想想更简单的版本

                  Your condition is flawed. Think about the simpler version

                  z != 'a' || z != 'e'
                  

                  如果 z'a' 则后半部分为真,因为 z 不是 'e' (即整个条件为真),如果 z'e' 则前半部分为真,因为 z 不是 'a' (同样,整个条件为真).当然,如果 z 既不是 'a' 也不是 'e' 那么这两个部分都为真.也就是说,你的条件永远不会是假的!

                  If z is 'a' then the second half will be true since z is not 'e' (i.e. the whole condition is true), and if z is 'e' then the first half will be true since z is not 'a' (again, whole condition true). Of course, if z is neither 'a' nor 'e' then both parts will be true. In other words, your condition will never be false!

                  你可能想要 && 代替:

                  z != 'a' && z != 'e' && ...
                  

                  或许:

                  "aeiou".indexOf(z) < 0
                  

                  这篇关于如何检查字符是否为元音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:char类型可以归类为整数吗? 下一篇:如何在 Java 中将 char 转换为 int?

                  相关文章

                  最新文章

                    1. <i id='ZXqAo'><tr id='ZXqAo'><dt id='ZXqAo'><q id='ZXqAo'><span id='ZXqAo'><b id='ZXqAo'><form id='ZXqAo'><ins id='ZXqAo'></ins><ul id='ZXqAo'></ul><sub id='ZXqAo'></sub></form><legend id='ZXqAo'></legend><bdo id='ZXqAo'><pre id='ZXqAo'><center id='ZXqAo'></center></pre></bdo></b><th id='ZXqAo'></th></span></q></dt></tr></i><div id='ZXqAo'><tfoot id='ZXqAo'></tfoot><dl id='ZXqAo'><fieldset id='ZXqAo'></fieldset></dl></div>

                    2. <small id='ZXqAo'></small><noframes id='ZXqAo'>

                      <tfoot id='ZXqAo'></tfoot>
                      • <bdo id='ZXqAo'></bdo><ul id='ZXqAo'></ul>
                      <legend id='ZXqAo'><style id='ZXqAo'><dir id='ZXqAo'><q id='ZXqAo'></q></dir></style></legend>