BubaLazi

p03_ FlowerFromIvancho

Mar 15th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FlowerFromIvancho {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(console.nextLine());
  8.  
  9.         int dots = 2 * n;
  10.         int wave = 0;
  11.         int middleDots = 0;
  12.         int dots1 = 1;
  13.         int middleDots1 = 2 * n;
  14.  
  15.  
  16.  
  17.         for (int i = 1; i <=n ; i++) {
  18.  
  19.  
  20.                 System.out.printf("#%s#%s#%s#%s#%s#\n",repeatStr("~", wave),
  21.                         repeatStr(".", dots ),repeatStr(".",middleDots),
  22.                         repeatStr(".", dots),repeatStr("~", wave));
  23.             dots-=2;
  24.             wave++;
  25.             middleDots+=2;
  26.                
  27.  
  28.            
  29.         }
  30.         for (int i = 0; i < n; i++) {
  31.  
  32.                 System.out.printf("%s#%s#%s#%s#%s \n",repeatStr(".",dots1),
  33.                         repeatStr("~", wave ),repeatStr(".", middleDots1 ),
  34.                         repeatStr("~", wave),repeatStr(".", dots1));
  35.             dots1+=2;
  36.             wave-=1;
  37.             middleDots1-=2;
  38.  
  39.  
  40.  
  41.  
  42.         }
  43.  
  44.  
  45.         System.out.printf("%s%s%s\n", repeatStr(".", (2 * n )+1),
  46.                 repeatStr("#", 4 ), repeatStr(".", (2 * n )+1));
  47.  
  48.         for (int i = 0; i < n; i++) {
  49.             System.out.printf("%s%s%s\n", repeatStr(".", (2 * n )+2),
  50.                     repeatStr("#", 2 ), repeatStr(".", (2 * n )+2));
  51.  
  52.         }
  53.  
  54.  
  55.     }
  56.  
  57.     static String repeatStr(String strToRepeat, int count) {
  58.         String text = "";
  59.  
  60.         for (int i = 0; i < count; i++) {
  61.             text = text + strToRepeat;
  62.         }
  63.  
  64.         return text;
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment