/*W.A.P. TO DISPLAY THEW FOLLOWING PATTERN WHERE THE ROW NUMBER IS ENTERED BY THE USER
0
1 0
0 1 0
1 0 1 0...........
FOR N NUMBER OF ROWS*/0
1 0
0 1 0
1 0 1 0...........
import java.io.*;
class pat
{
public static void main(String args[])
{
int i,j,n,k;
DataInputStream in=new DataInputStream(System.in);
try
{
System.out.print("Enter a no");
n=Integer.parseInt(in.readLine());
for(i=1;i<=n;i++)
{
k=i%2;
for(j=1;j<=i;j++)
{
System.out.print(k);
k=1-k;
}
System.out.println();
}
}
catch(Exception e){}
}
}
No comments:
Post a Comment