Following Code Will print the Rhombus Structure :
Code::
import java.util.*;
public class Rhombus
{
public static void main(String[] nt)
{
Scanner in=new Scanner(System.in);
System.out.print("Enter Number of Rows: ");
int n=in.nextInt();
int count=1,c,space=0;
for(int i=1;i<2*n;i++)
{
if(i<=n)
{
c=i;
space++;
}
else
{
c=2*n-i;
space--;
}
for(int spc=n-space;spc>0;spc--)
{
System.out.print(" ");
}
for(int j=0;j<count;j++)
{
System.out.print(c);
if(j<count/2)
{
c--;
}
else
{
c++;
}
}
if(i<n)
{
count=count+2;
}
else
{
count=count-2;
}
System.out.println();
}
}
}
Output::
Code::
import java.util.*;
public class Rhombus
{
public static void main(String[] nt)
{
Scanner in=new Scanner(System.in);
System.out.print("Enter Number of Rows: ");
int n=in.nextInt();
int count=1,c,space=0;
for(int i=1;i<2*n;i++)
{
if(i<=n)
{
c=i;
space++;
}
else
{
c=2*n-i;
space--;
}
for(int spc=n-space;spc>0;spc--)
{
System.out.print(" ");
}
for(int j=0;j<count;j++)
{
System.out.print(c);
if(j<count/2)
{
c--;
}
else
{
c++;
}
}
if(i<n)
{
count=count+2;
}
else
{
count=count-2;
}
System.out.println();
}
}
}
Output::