piexil

Untitled

Nov 6th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. /**
  2.  * Created with IntelliJ IDEA.
  3.  * User: Bobby
  4.  * Date: 11/7/13
  5.  * Time: 12:58 PM
  6.  * To change this template use File | Settings | File Templates.
  7.  */
  8. public class triangles {
  9.     public static void main( String args[]){
  10.         int row;
  11.         int column;
  12.         int space;
  13.         //triangle 1
  14.         for(row = 1; row<=10; row++){
  15.             for(column = 1; column <= row && column <=10; column++){
  16.                 System.out.print("*");
  17.             }
  18.              System.out.println();
  19.  
  20.         }
  21.  
  22.             System.out.println();
  23.  
  24.  
  25.         for(row = 1; row<=10; row++){
  26.             for(column = 10; column >= row && column <=10; column--){
  27.                 System.out.print("*");
  28.             }
  29.             System.out.println();
  30.         }
  31.         System.out.println();
  32.  
  33.         //third  triangle
  34.         for(row = 10; row >=1; row--){
  35.             for(space = 10; space >= row; space--){
  36.                 System.out.print(" ");
  37.             }
  38.             for(column = 1; column <= row && column <=10; column++){
  39.                 System.out.print("*");
  40.             }
  41.             System.out.println();
  42.         }
  43.         System.out.println();
  44.  
  45.         //fourth  triangle
  46.         for(row = 10; row >=1; row--){
  47.             for(space = 1; space <= row; space++){
  48.                 System.out.print(" ");
  49.             }
  50.             for(column = 10; column >= row && column <=10; column--){
  51.                 System.out.print("*");
  52.             }
  53.             System.out.println();
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment