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

        <legend id='CYukm'><style id='CYukm'><dir id='CYukm'><q id='CYukm'></q></dir></style></legend>

      1. <tfoot id='CYukm'></tfoot>

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

        在java中制作一个倒三角形

        时间:2023-09-30
          <legend id='VXnNW'><style id='VXnNW'><dir id='VXnNW'><q id='VXnNW'></q></dir></style></legend>

                  <tbody id='VXnNW'></tbody>

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

              • <tfoot id='VXnNW'></tfoot>
                • <bdo id='VXnNW'></bdo><ul id='VXnNW'></ul>
                  <i id='VXnNW'><tr id='VXnNW'><dt id='VXnNW'><q id='VXnNW'><span id='VXnNW'><b id='VXnNW'><form id='VXnNW'><ins id='VXnNW'></ins><ul id='VXnNW'></ul><sub id='VXnNW'></sub></form><legend id='VXnNW'></legend><bdo id='VXnNW'><pre id='VXnNW'><center id='VXnNW'></center></pre></bdo></b><th id='VXnNW'></th></span></q></dt></tr></i><div id='VXnNW'><tfoot id='VXnNW'></tfoot><dl id='VXnNW'><fieldset id='VXnNW'></fieldset></dl></div>
                • 本文介绍了在java中制作一个倒三角形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使我制作的三角形面朝下.试了很多次,不知道怎么弄.

                  I am trying to make the triangle I have made up side down. Tried many times, but I don't know how to do this.

                  我知道的代码是:

                  public static void drawPyramide(int lines, char symbol, boolean startDown) {
                      //TRIANGLE
                  
                      if(startDown) {
                                  //The triangle up side down should be here. 
                              }
                  
                      else {
                          int c = 1;
                          for (int i = 0; i < lines; i++) {
                              for (int j = i; j < lines; j++) {
                                  System.out.print(" ");
                              }
                              for (int k = 1; k <= c; k++) {
                                  if (k%2==0) System.out.print(" ");
                  
                                  else System.out.print(symbol);
                              }
                  
                          System.out.print("
                  ");
                          c += 2;
                          }
                      }
                  
                  }
                  

                  有什么建议可以翻转"这个三角形吗?谢谢.

                  Any suggestions how I can "flip" this triangle? Thanks.

                  推荐答案

                  要翻转三角形,你真的只需要改变迭代的方向.而不是从 i = 0i <lines 你需要从 i = lines-1i >= 0

                  To flip the triangle you really just need to change the direction of iteration. Instead of going from i = 0 to i < lines you need to go down from i = lines-1 to i >= 0

                  您还需要将 c 更改为要以多少个空格和符号开头.

                  You also need to change the c to how many spaces and symbols you want to start with.

                  可能是这样的:

                  int c = 2*lines;
                  for (int i = lines-1; i>=0; i--)
                  {
                      for (int j = i; j < lines; j++)
                      {
                          System.out.print(" ");
                      }
                      for (int k = 1; k <= c; k++)
                      {
                          if (k % 2 == 0)
                          {
                              System.out.print(" ");
                          }
                          else
                          {
                              System.out.print(symbol);
                          }
                      }
                  
                      System.out.print("
                  ");
                      c -= 2;
                  }
                  

                  这篇关于在java中制作一个倒三角形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在jframe中创建java的正方形、矩形、三角形 下一篇:从三个点找到圆心的算法是什么?

                  相关文章

                  最新文章

                  1. <small id='ZDKnh'></small><noframes id='ZDKnh'>

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

                      <tfoot id='ZDKnh'></tfoot>