Advertisement
cd62131

Print Triangle

Dec 11th, 2013
1,270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.36 KB | None | 0 0
  1. public class Triangle {
  2.   public static void main(String[] args) {
  3.     int n = 10;
  4.     StringBuilder sb = new StringBuilder();
  5.     for (int i = n; i > 0; i--) {
  6.       for (int j = 0; j < n - i; j++)
  7.         sb.append(" ");
  8.       for (int j = 0; j < i; j++)
  9.         sb.append("○");
  10.       sb.append("\n");
  11.     }
  12.     System.out.print(sb.toString());
  13.   }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement