zoukankan      html  css  js  c++  java
  • java实现杨辉三角

    import java.io.*;

    public class yanghuisanjiao {

     /**   * @param args   */  

    public static void main(String[] args) throws IOException{   

    // TODO Auto-generated method stub   

    int i,n;   

    String str;   

    while(true)
      {

    BufferedReader buf;   

    buf=new BufferedReader(new InputStreamReader(System.in));   

    System.out.println("输入一个n");   

    str=buf.readLine();   

    n=Integer.parseInt(str);   

     if("bye".equals(str)){
                  break;
              }

    for(i=0;i<n;i++)  

     {    

      for(int j=0;j<n-1-i;j++)    

         System.out.print(" ");    

      for(int k=0;k<2*i+1;k++)     

        System.out.print("*");    

    System.out.println();   

    }  

     

    }

    }

    加入 的红色部分可以实现连续输入,想要停止可输入bye

  • 相关阅读:
    HTML5学习总结-番外05 http 状态码
    Python开发技巧
    QPushButton class
    Qt class
    QTableWidgetItem class
    毕业设计进度10
    毕业设计进度9
    毕业设计进度8
    毕业设计进度7
    毕业设计进度6
  • 原文地址:https://www.cnblogs.com/iris-yx/p/3378417.html
Copyright © 2011-2022 走看看