Advertisement
taweesoft

Untitled

Sep 14th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. //elab-source: TaweeLab.java
  2. import java.util.ArrayList;
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class TaweeLab {
  7.  
  8. public static void main (String [] args){
  9.         Scanner input = new Scanner (System.in);
  10.         String s ="$";
  11.         int p = input.nextInt();
  12.         for(int i =1;i<=p;i++){
  13.             for(int j=1;j<=p-i;j++){
  14.             System.out.print(" ");
  15.             }
  16.             if(i==p){
  17.                 for(int k=1;k<=2*p-1;k++){
  18.                     if(k%2!=0){
  19.                         System.out.print(s);
  20.                     }else{
  21.                         System.out.print(" ");
  22.                     }
  23.                 }
  24.             }else{
  25.                 for(int j=1;j<=2*i-1;j++){
  26.                 if(j==1||j==2*i-1){
  27.                     System.out.print(s);
  28.                 }else{
  29.                     System.out.print(" ");
  30.                 }
  31.             }
  32.             }
  33.            
  34.             System.out.println();
  35.         }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement