• 九九乘法表的四种三角形排布方式(for循环以及while循环的互换)


    #region

    //右上
      for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
          if (i > j){
            Console.Write(" ");
          } else{
            Console.Write("{0}*{1}={2} ", i, j, i * j);
          }
        }
          Console.Write(" ");
      }
      Console.ReadKey();
    //右下
       for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){

          if (i < 9 + 1 - j){
            Console.Write(" ");
          }else{
            Console.Write("{0}*{1}={2} ", i, j, i * j);
          }

        }
        Console.Write(" ");
       }
        Console.ReadKey();
        Console.Write(" 上层结束 ");



    //左上
      for (int i = 1; i <= 9; i++){
        for (int j = i; j <= 9; j++)
        {
          if (i > j){
            Console.Write(" ");
          } else{
            Console.Write("{0}*{1}={2} ", i, j, i * j);
          }
        }
        Console.Write(" ");
      }
        Console.ReadKey();
        Console.Write(" ");

    //左下
      for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
          if (i <j){
            Console.Write(" ");
          }else{
            Console.Write("{0}*{1}={2} ", i, j, i * j);
          }  
        }
        Console.Write(" ");
      }
        Console.ReadKey();
        Console.Write(" ");
    //右上
      for (int i = 1; i <= 9; i++){
        for (int a = 1;a < i; a++){
          Console.Write(" ");
        }
      for (int j = i; j <= 9; j++) {
        Console.Write("{0}*{1}={2} ", i, j, i * j);
      }
        Console.Write(" ");
      }
      Console.ReadKey();
      Console.Write(" ");

    #endregion

    附加运行结果:

  • 相关阅读:
    奔跑的绵羊js
    13.差分
    12.子矩阵的和
    11.前缀和
    10.高精度除法
    9.高精度乘法
    8.高精度减法
    7.高精度加法
    6.数的三次方根
    5.数的范围
  • 原文地址:https://www.cnblogs.com/Kai-YoungMaster/p/12375174.html
Copyright © 2020-2023  润新知