Print Diamond Number Pattern Program Type 2

6 comments on “Print Diamond Number Pattern Program Type 2”


  • Sudip

    import java.util.*;
    public class Main
    {
    public static void main(String[] args) {
    int row,col,i,j,k,val;
    Scanner sc=new Scanner(System.in);
    row=sc.nextInt();
    val=row-1;
    for(i=1;i<=row;i++)
    {
    for(j=1;j=1;i–)
    {
    for(j=1;j<=i;j++)
    {
    System.out.print(val++);

    }
    System.out.println();
    val=val/2;
    }
    }
    }


  • Divya

    import java.util.Scanner;
    public class Main
    {
    public static void main(String[] args) {
    int k=0;
    Scanner sc=new Scanner(System.in);
    int n= sc.nextInt();

    for(int i=1;i<=((n%2==0)?n/2:(n/2)+1);i++){
    for(int j=1;j=1;i–){
    for(int j=i;j>=1;j–){

    System.out.print(k);
    k–;
    }
    System.out.println();

    }
    }
    }


    • Divya

      import java.util.Scanner;
      public class Main
      {
      public static void main(String[] args) {
      int k=0;
      Scanner sc=new Scanner(System.in);
      int n= sc.nextInt();
      for(int i=1;i<=((n%2==0)?n/2:(n/2)+1);i++){
      for(int j=1;j=1;i–){
      for(int j=i;j>=1;j–){
      System.out.print(k);
      k–;
      }
      System.out.println();
      }
      }
      }


  • akashrana rana

    public class Main
    {
    public static void main(String[] args) {
    int n=7;int count=0;int sum=2;int c=1;
    for(int i=1;i<=n;i++){
    if(i<=n/2+1){
    sum=sum+c;count+=1;
    int s=sum;
    for(int j=0;j<count;j++){
    System.out.print(s–);
    }
    c=c+1;
    }
    else{
    c=c-1;
    sum=sum-c;count-=1;
    int s=sum;
    for(int j=0;j<count;j++){
    System.out.print(s–);
    }

    }
    System.out.println();
    }

    }
    }