金字塔

题一:

 

public class S1 {

 public static void main(String[] args){

  for(int i = 1; i <= 5; i++){

   int b = i;

   while(b != 0){

    System.out.print("*");

    b--;

   }

   System.out.print("\n");

   }

  }

 }

}

题二:



 

public class S3 {

 public static void main(String[] args){

  for(int i = 1;i <= 5;i++){

   int x = (2 * i) - 1;

   int k = 0;

   while(k != 5 - i){

    System.out.print(" ");

    k++;

   }

   while(x != 0){

    System.out.print("*");

    x--;

   }

   System.out.print("\n");

  }

 }

}

题三:

 

public class S2 {

 public static void main(String[] args){

  for(int i = 1; i <= 9; i++){

   for(int j = 1; j <= i; j++){

    System.out.print(" "+i+"*"+j+"="+i*j+" ");

   }

   System.out.print("\n");

  }

 }

}

猜你喜欢

转载自zyq519300242.iteye.com/blog/2265325