dimanche 4 décembre 2022

What i do To correct it and make this pattern?? can anybody plss help me [closed]

class Pattern27
{
  public static void main(String args[])
  {
    int i,j,k,space,rows;  
    System.out.println("Enter number of rows:-");
    rows=new java.util.Scanner(System.in).nextInt();
    for(i=1;i<=rows;i++)
    {
        for(space=1;space<=rows-i;space++)
        {
            System.out.print(" ");
            k=i;
        }
        for(j=1;j<=i;j++)
        {
            System.out.print(k++);
            k=k-2;
        }
        for(j=1;j<i;j++)
        {
            System.out.print(k--);
        }
        System.out.println("");
    }
  }
}

Pattern: 1 232 34543 4567654 567898765 plss help it shows k is not initialized when i initialized it at 1 or 0 pattern is not correct plss correct my program and tell me what is my mistake.

I want a correct pattern .. and want to know what is my mistake.

Aucun commentaire:

Enregistrer un commentaire