Facebook
From Sweet Leopard, 2 Years ago, written in Plain Text.
This paste is a reply to Untitled from Subtle Mousedeer - view diff
Embed
Download Paste or View Raw
Hits: 105
  1. public class Task
  2. {
  3.         public static void main(String[] args) {
  4.                 int[] arr={3, 1, 2, 3, 6, 2, 3, 6, 2, 3};
  5.                 int maxheight=arr[0];
  6.                 int currheight=0;
  7.                 int width=0;
  8.                 for(int i=0;i<arr.length;i++)
  9.                 {
  10.                     width=width+arr[i];
  11.                     if(i%2==0)
  12.                     {
  13.                         currheight=currheight+arr[i];
  14.                     }
  15.                     else
  16.                     {
  17.                         currheight=currheight-arr[i];
  18.                     }
  19.                     if(currheight>maxheight)
  20.                     maxheight=currheight;
  21.                 }
  22.  
  23.                
  24.                 char[][] result=new char[maxheight + 3][width + 1];
  25.                 int x=maxheight-1 + 3, y=0;
  26.  
  27.                 for(int i=0;i<arr.length;i++)
  28.                 {
  29.                     if(i % 2==0) //////
  30.                     {
  31.                         for(int j=0;j<arr[i];j++)
  32.                         {
  33.                             result[x][y]='/';
  34.                             x--;
  35.                             y++;
  36.                         }
  37.                                 if(x < result.length - maxheight){
  38.                                         result[x][y - 1] = '<';
  39.                                         result[x][y + 1] = '>';
  40.                                         result[x - 1][y] = '|';
  41.                                         result[x - 1][y - 1] = '/';
  42.                                         result[x - 1][y + 1] = '\\';
  43.                                         result[x - 2][y] = 'o';
  44.                                         y++;
  45.                                 }
  46.                         x++;
  47.                     }
  48.                     else
  49.                     {
  50.                         for(int j=0;j<arr[i];j++)
  51.                         {
  52.                             result[x][y]='\\';
  53.                             x++;
  54.                             y++;
  55.                         }
  56.                         x--;
  57.                     }
  58.                    
  59.                 }
  60.                
  61.                 for(int i=0;i<result.length;i++)
  62.                 {
  63.                     for(int j=0;j<result[0].length;j++)
  64.                     {
  65.                         if(result[i][j] != '\0')
  66.                         System.out.print(result[i][j]);
  67.                         else
  68.                         System.out.print(" ");
  69.                     }
  70.                     System.out.println();
  71.                 }
  72.         }
  73. }