Advertisement
Guest User

Untitled

a guest
Apr 5th, 2011
4,669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class Gavnokod1
  2. {
  3.     final static int N = 6;
  4.    
  5.     public static void main( String[] args ) {
  6.         for( int row=1; row<=N; row++ )  {
  7.             if( row%2 == 1 ) {
  8.                 for( int pos=1; pos<=row; pos++ ) {
  9.                     System.out.print(pos);
  10.                     if(pos!=row)System.out.print("-");
  11.                 }
  12.             }
  13.             else
  14.             {
  15.                 for( int pos=row; pos>=1; pos-- ) {
  16.                     System.out.print(pos);
  17.                     if(pos!=1)System.out.print("-");
  18.                 }
  19.             }          
  20.             System.out.println();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement