Advertisement
Guest User

Untitled

a guest
Apr 5th, 2011
840
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class Govnokod {
  2.  
  3.     final static String DELIMITER = "-";
  4.     final static int LINES_NUM = 6;
  5.    
  6.     protected static int getCurrentNumber(int lineNumber, int posInLine) {
  7.         int currentNumber;
  8.         if (lineNumber % 2 == 0) {
  9.             currentNumber = posInLine + 1;
  10.         } else {
  11.             currentNumber = (lineNumber - posInLine) + 1;
  12.         }
  13.         return currentNumber;
  14.     }
  15.    
  16.     public static void main(String[] args) {
  17.  
  18.         for (int lineNumber = 0; lineNumber < LINES_NUM; lineNumber ++) {
  19.             for (int posInLine = 0; posInLine < lineNumber + 1; posInLine ++) {
  20.                 if (posInLine != 0) {
  21.                     System.out.print(DELIMITER);
  22.                 }
  23.                 int currentNumber = getCurrentNumber(lineNumber, posInLine);
  24.                 System.out.print(currentNumber);
  25.             }
  26.             System.out.println();
  27.         }
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement