How to make a diamond using Nested For Loops

后端 未结 15 1137
终归单人心
终归单人心 2021-01-01 07:09

So I was assigned to make a diamond with asterisks in Java and I\'m really stumped. Here\'s what I\'ve come up with so far:

public class Lab1 
{
   public s         


        
15条回答
  •  被撕碎了的回忆
    2021-01-01 07:45

    public class MyDiamond
    {
       public static void main(String[] args)
       {
          int numRows=151;//Length of the pyramid that we want.151 is just an example
          int midrow = (numRows+1)/2;//midrow is the middle row and has numRows number of *
    
          int diff=0;
          for(int i=1;i

提交回复
热议问题