Print the alternate traingle of 0 and 1.

class AlternetPrint
  {
    public static void main(String args[])
     {
       int i,j,a=1;
        for(i=0;i<=9;i++)
         {
           i++;
           for(j=a;j<=i;j++)
             {
               int k=j%2;
               System.out.print(k);
              
             }a++;
            System.out.println(" ");
         }
      }
  }

No comments:

Post a Comment