Creation of triangle in java

Saturday, March 21, 2009

import java.io.*; class Binary { public static void main(String args[])throws IOException { String a,b,c; int n,j,k; BufferedReader BR=new BufferedReader(new InputStreamReader(System.in)); a=BR.readLine(); n=Integer.parseInt(a); int r; for(int i=1;i<=n;i++) { for( j=1,r=i;j<=i;j++,r++) { System.out.printf("%4d",r%2); } System.out.printf("\n\n"); } } }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP