其他分享
首页 > 其他分享> > 打印空心pyramid

打印空心pyramid

作者:互联网

  

 

import java.util.Scanner;

public class B{
  public static void main(String[] args){
    Scanner scanner1 = new Scanner(System.in);    
    byte level=scanner1.nextByte();
    for(byte i=1;i<=level;++i){
      for(byte j=0;j<level-i;++j){
        System.out.print(' ');
      }
      for(byte k=0;k<2*i-1;++k){
        if(k==0 || k==2*i-2 || i==level){
          System.out.print('*');
        }else{
          System.out.print(' ');
        }
      }
      System.out.println();
    }
  }
}

 

public class B{
  public static void main(String[] args){
    for(char b='a';b<='z';++b){
      System.out.println(b+" ");
    }
  }
}

 

public class B{
  public static void main(String[] args){
    for(char b='Z';b>='A';--b){
      System.out.println(b+" ");
    }
  }
}

 

标签:pyramid,String,args,void,打印,空心,static,main,public
来源: https://www.cnblogs.com/dissipate/p/14775565.html