Facebook
From Subtle Mousedeer, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 80
  1. public class task
  2. {
  3.         public static void main(String[] args) {
  4.                 int[] arr={10,7,2,5,2,20};
  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.                 char[][] result=new char[maxheight][width];
  23.                 int x=maxheight-1,y=0;
  24.                 for(int i=0;i<arr.length;i++)
  25.                 {
  26.                     if(arr[i]%2==0)
  27.                     {
  28.                         for(int j=0;j<arr[i];j++)
  29.                         {
  30.                             result[x][y]='/';
  31.                             x--;
  32.                             y++;
  33.                         }
  34.                         x++;
  35.                         //y++;
  36.                     }
  37.                     else
  38.                     {
  39.                         for(int j=0;j<arr[i];j++)
  40.                         {
  41.                             result[x][y]='\\';
  42.                             x++;
  43.                             y++;
  44.                         }
  45.                         x--;
  46.                         //y++;
  47.                     }
  48.                    
  49.                 }
  50.                 for(int i=0;i<maxheight;i++)
  51.                 {
  52.                     for(int j=0;j<width;j++)
  53.                     {
  54.                         if(result[i][j]=='/' || result[i][j]=='\\')
  55.                         System.out.print(result[i][j]);
  56.                         else
  57.                         System.out.print(" ");
  58.                     }
  59.                     System.out.println();
  60.                 }
  61.         }
  62. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Sweet Leopard text 2 Years ago.