Advertisement
xapu

Untitled

Jun 3rd, 2017
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. /**
  5.  * Created by Asus on 03/06/2017.
  6.  */
  7. public class test {
  8.     public static void main(String[] args) {
  9.         Scanner sc = new Scanner(System.in);
  10.  
  11.         String mykey = "*";
  12.         int n = Integer.parseInt(sc.nextLine());
  13.  
  14.         for(int i = n-1; i>0; i--){
  15.             System.out.print(printer(" ",i));
  16.             System.out.print(printer("* ", n-i));
  17.             System.out.println();
  18.         }
  19.  
  20.         for(int i = 0; i<n; i++){
  21.             System.out.print(printer(" ",i));
  22.             System.out.print(printer("* ", n-i));
  23.             System.out.println();
  24.         }
  25.  
  26.         printer(mykey,n);
  27.     }
  28.  
  29.     private static String printer(String mykey, int n) {
  30.  
  31.         String result = "";
  32.  
  33.         for(int i =0; i<n; i++){
  34.             result+=mykey;
  35.         }
  36.  
  37.         return result;
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement