Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit Pattern20 #20

Closed
ErSKS opened this issue Jul 27, 2017 · 25 comments
Closed

Submit Pattern20 #20

ErSKS opened this issue Jul 27, 2017 · 25 comments

Comments

@ErSKS
Copy link
Owner

ErSKS commented Jul 27, 2017

pattern20

@milan604
Copy link

package pattern18;

/**
*

  • @author m-lan
    */
    public class Pattern18 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      char[] a = {'A', 'B', 'C', 'D'};
      int b = 0;
      for (int i = 1; i <= a.length; i++) {
      for (int j = 2; j <= i; j++) {
      System.out.printf(" ");

       }
       int c = b;
       for (int k = a.length; k >= i; k--) {
           System.out.printf("%c", a[c]);
           c++;
      
       }
       b++;
      
       for (int l = a.length; l > i; l--) {
           System.out.printf("%c", a[l - 2]);
       }
       System.out.println("");
      

      }
      }

}

screenshot from 2017-07-27 14-09-47

@jagdish4249
Copy link

package pattern17;

/**
*

  • @author jagdish
    */
    public class Pattern17 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] a = {'A','B','C','D'};

      int l = a.length;
      for ( int i = l; i >= 1; i--) {
      int z = l-i;
      for ( int j = l; j >= 1 ; j--) {

           if(i<j){
               System.out.print(" ");   
           }  
           else{
               System.out.print(a[z]);
                 z++;
           }   
       }
       z = l-2;
       for (int k = 1; k <= l-1; k++) {
            
            if((i-1)>=k){
               System.out.print(a[z]);
               z--;
            }
            
       }
      

      System.out.println("");
      }
      }

}

image

@raBbn
Copy link

raBbn commented Jul 27, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package pattern19;

/**
*

  • @author Kishorr
    */
    public class Pattern19 {

    /**
    *

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] arr1 = {'A', 'B', 'C', 'D'};

      for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
      if (j < i) {
      System.out.print(" ");
      } else {
      System.out.print(arr1[j] + " ");
      }
      }
      for (int j = 2; j >= i; j--) {
      System.out.print(arr1[j] + " ");
      }
      System.out.println("");
      }

    }

}
capture17

@pujanchangubhari73
Copy link

package forpattern29;

/**
*

  • @author Pujan
    */
    public class ForPattern29 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] a = {'A', 'B', 'C', 'D'};
      int n = 3; //same to array length

      for (int i = 0; i <= a.length - 1; i++) {

       for (int l = 0; l <= i; l++) {
           System.out.printf(" " + " ");
       }
       for (int j = i; j <= n; j++) {
           System.out.print(a[j] + " ");
       }
      
       for (int k = n - 1; k >= i; k--) {
           System.out.print(a[k] + " ");
       }
       System.out.println();
      

      }
      }

}

image

@maheshyakami
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package pattern;

/**
*

  • @author mahesh
    */
    public class Pattern {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] alpha = {'A', 'B', 'C', 'D', 'E'};
      final int N = alpha.length;
      for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
      if (j < i) {
      System.out.print(" ");
      } else {
      System.out.print(alpha[j]);
      }
      }
      for (int j = N - 2; j >= i; j--) {
      System.out.print(alpha[j]);
      }
      System.out.println("");
      }
      System.out.println();

    }

}
screen shot 2017-07-27 at 5 31 08 pm

@sthaanu
Copy link

sthaanu commented Jul 27, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package pattern20;

/**
*

  • @author admin
    */
    public class Pattern20 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      char[] a = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < a.length; i++) {
      for (int j = 0; j < a.length; j++) {
      if (j >= i) {
      System.out.print(a[j]);
      } else {
      System.out.print(" ");
      }
      }
      for (int j = a.length - 2; j >= 0; j--) {
      if (j >= i) {
      System.out.print(a[j]);
      } else {
      System.out.print(" ");
      }

       }
       System.out.println("");
      

      }
      }
      }
      capture

@kiir33
Copy link

kiir33 commented Jul 27, 2017

package pattern8;

/**
*

  • @author KIRANN
    */
    public class Pattern8 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] a = {'A', 'B', 'C', 'D', 'E'};
      int i, j;
      final int N = 5

      System.out.println("Pattern 20\n----------------------");
      for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++) {
      if (j < i) {
      System.out.print("\t");
      } else {
      System.out.print(a[j] + "\t");
      }
      }
      for (j = N - 2; j >= i; j--) {
      System.out.print(a[j] + "\t");
      }
      System.out.println("");
      }

    }
    }
    Output:
    capture

@karmi214
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package pattern20;

/**
*

  • @author Anish
    */
    public class Pattern20 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] a = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < a.length; i++) {
      for (int j = 0; j < a.length; j++) {
      if (j >= i) {
      System.out.print(a[j]);
      } else {
      System.out.print(" ");
      }
      }
      for (int j = a.length - 2; j >= 0; j--) {
      if (j >= i) {
      System.out.print(a[j]);
      } else {
      System.out.print(" ");
      }

       }
       System.out.println("");
      

      }

    }

}
p20

@sajanbasnet75
Copy link

/*

To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
/
package assignment2;
/*
*

@author LORDsajan
*/
public class Assignment2 {

/**

@param args the command line arguments
/
public static void main(String[] args) {
System.out.println("\nPattern 20");
char[] ch = {'A', 'B', 'C', 'D'};
for (int i = 0; i < ch.length; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(" ");
}
for (int j = i; j < ch.length; j++) {
System.out.print(ch[j]);

        }
        for (int k = ch.length - 2; k >= i; k--) {
            System.out.print(ch[k]);
        }
        System.out.println(" ");
    }

}
}
20

@ghost
Copy link

ghost commented Jul 27, 2017

package pattern21;

/**
*

  • @author Samikshya
    */
    public class Pattern21 {

    public static void main(String[] args) {
    char n[] = {'A', 'B', 'C', 'D'};
    for (int i = 0; i < 4; i++) {
    for (int j = 0; j < i; j++) {
    System.out.print(" ");

         }
         for (int k = i; k < 4; k++) {
             System.out.print(n[k]);
    
         }
         for (int k = 2; k >= i; k--) {
             System.out.print(n[k]);
    
         }
    
         System.out.println("");
    
     }
    

    }
    }

capture

@kajalmaharjan
Copy link

//PATTERN 21
char[] n5 = {'A', 'B', 'C', 'D'};
for (int i = 0; i < n5.length; i++) {
for (int j = 0; j < i; j++) {
System.out.print(" ");
}
for (int j = i; j < n5.length; j++) {
System.out.print(n5[j]);
}
for (int j = 2; j >= i; j--) {
System.out.print(n5[j]);
}
System.out.println("");
}
image

@syslin
Copy link

syslin commented Jul 27, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package paterrn;

/**
*

  • @author dell
    */
    public class Paterrn {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("pattern 21");
      char b[] = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < b.length; i++) {
      for (int j = 0; j < b.length; j++) {
      if (j >= i) {
      System.out.print(b[j]);
      } else {
      System.out.print(" ");

           }
      
       }
      
       for (int k = b.length - 2; k >= 0; k--) {
           if (k >= i) {
               System.out.print(b[k]);
      
           } else {
               System.out.print("");
           }
       }
       System.out.println(" ");
      

      }
      }
      }
      21

@RakenShahi
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package q18;

/**
*

  • @author DELL
    */
    public class Q18 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {

      int b = 4;
      int c = 0;

      char[] a = {'A', 'B', 'C', 'D'};
      for (int i = 0; i <= 3; i++) {

       for (int k = 0; k < i; k++) {
           System.out.printf(" ");
       }
      
       for (int j = i; j < b; j++) {
      
           System.out.printf("%c", a[j]);
      
       }
       for (int l = 2; l >= c; l--) {
           System.out.printf("%c", a[l]);
       }
       c = c + 1;
       System.out.print("\n");
      

      }

    }

}

OUTPUT
18

@Roshantwanabasu
Copy link

Code:
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package letterdiamond;

/**
*

  • @author NiiRosh
    */
    public class Letterdiamond {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] a = {'A', 'B', 'C', 'D'};

      for (int i = 0; i < a.length; i++) {
      for (int j = 0; j < a.length; j++) {
      if (j < i) {
      System.out.print(" ");
      } else {
      System.out.print(a[j]);
      }
      }
      for (int j = a.length - 2; j >= i; j--) {
      System.out.print(a[j]);
      }
      System.out.println("");
      }
      }

}

Output:
pattern20

@leoprabin10
Copy link

public static void main(String[] args) {
char[] a = {'A', 'B', 'C', 'D'};
for (int i = 0; i < 5 - 1; i++) {
for (int j = 0; j < 5 - 1; j++) {
if (j < i) {
System.out.print(" ");
} else {
System.out.print(a[j] + " ");
}
}
for (int j = 5 - 3; j >= i; j--) {
System.out.print(a[j] + " ");
}
System.out.println();
}
image

@Rajjushrestha
Copy link

char[] a = {'A', 'B', 'C', 'D'};
for (inti = 0; i<a.length; i++) {
for (int j = 0; j <a.length; j++) {
if (j >= i) {
System.out.print(a[j]);
} else {
System.out.print(" ");
}
}
for (int j = a.length - 2; j >= 0; j--) {
if (j >= i) {
System.out.print(a[j]);
} else {
System.out.print(" ");
}

        }

System.out.println("");
21

@rivab
Copy link

rivab commented Jul 27, 2017

System.out.println("Output of Q.No.21");
char[] b = {'A', 'B', 'C', 'D'};
for (int i = 0; i < b.length; i++) {
for (int j = 0; j < i; j++) {
System.out.print(" ");
}
for (int k = 0; k < b.length - i; k++) {
System.out.print(b[k + i]);
}
for (int l = 1; l < b.length - i; l++) {
System.out.print(b[b.length - 1 - l]);
}
System.out.println(" ");
}

21

@Sudan15423
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day4;

/**
*

  • @author dragon15423
    */
    public class Day4 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      for (int i = 0; i <= b.length - 1; i++) {
      for (int j = 1; j <= i; j++) {
      System.out.print(" ");
      }
      for (int j = i; j <= b.length - 1; j++) {
      System.out.print(b[j]);
      }
      for (int j = b.length - 2; j >= i; j--) {
      System.out.print(b[j]);
      }
      System.out.println();
      }
      }
      Output:
      20

@ajay987
Copy link

ajay987 commented Jul 29, 2017

patt20sol
patt20sol

    char[] b = {'A', 'B', 'C', 'D', 'C', 'B', 'A'};
    for (int i = 0; i < b.length; i++) {
        if (i == 0) {
            for (int j = 0; j < b.length; j++) {
                System.out.print(b[j]);
            }
        } else {
            for (int l = 0; l < i; l++) {
                System.out.print(" ");

            }

            for (int k = i; k < b.length - i; k++) {
                System.out.print(b[k]);

            }
        }

        System.out.println();
    }

@ghost
Copy link

ghost commented Jul 29, 2017

package patterntwenty;

/**
*

  • @author User
    */
    public class PatternTwenty {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      char[] a = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < a.length; i++) {
      for (int j = 0; j < a.length; j++) {
      if (j < i) {
      System.out.print(" ");
      }
      else {
      System.out.print(a[j]);
      }
      }
      for (int k = a.length - 2; k >= i; k--) {
      System.out.print(a[k]);
      }
      System.out.println(" ");
      }
      }
      }
      patt20

@rituratnam
Copy link

CODE:
package pattern20;

/**
*

  • @author Lavalesh
    */
    public class Pattern20 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      char[] b = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < b.length; i++) {
      for (int j = 0; j < i; j++) {
      System.out.print(" ");
      }
      for (int k = 0; k < b.length - i; k++) {
      System.out.print(b[k + i]);
      }
      for (int l = 1; l < b.length - i; l++) {
      System.out.print(b[b.length - 1 - l]);
      }
      System.out.println(" ");
      }
      }
      }
      Output:
      pattern20

@duwalshraddha
Copy link

Code
package pattern18;

/**
*

  • @author Lenovo
    */
    public class Pattern18 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      char[] a = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < a.length; i++) {
      for (int j = 0; j < i; j++) {
      System.out.print(" ");
      }
      for (int j = i; j < a.length; j++) {
      System.out.print(a[j]);
      }
      for (int j = 2; j >= i; j--) {
      System.out.print(a[j]);
      }
      System.out.println("");
      }
      }

}
188

@SusanCB
Copy link

SusanCB commented Jul 29, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package pat18;

/**
*

  • @author nissus
    */
    public class Pat18 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {

      char[] ch = {'A', 'B', 'C', 'D'};
      for (int i = 0; i < ch.length; i++) {
      for (int j = 1; j <= i; j++) {
      System.out.print(" ");
      }
      for (int j = i; j < ch.length; j++) {
      System.out.print(ch[j]);

       }
       for (int k = ch.length - 2; k >= i; k--) {
           System.out.print(ch[k]);
       }
       System.out.println(" ");
      

      }
      }
      // TODO code application logic here
      }

pat18

@sarumdr
Copy link

sarumdr commented Jul 29, 2017

public class Pattern20 {

/**

@param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
char[] a = {'A', 'B', 'C', 'D', 'E'};
int i, j;
int N = 5
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (j < i) {
System.out.print("\t");
} else {
System.out.print(a[j] + "\t");
}
}
for (j = N - 2; j >= i; j--) {
System.out.print(a[j] + "\t");
}
System.out.println("");
}

}
}

OUTPUT
image

@sanzeevtamang
Copy link

//pattern 20
char[] b = {'A', 'B', 'C', 'D'};
for (int i = 0; i < b.length; i++) {
for (int j = 0; j < b.length; j++) {
if (j >= i) {
System.out.print(b[j]);
} else {
System.out.print(" ");
}
}

        for (int j = b.length - 2; j >= 0; j--) {
            if (j >= i) {
                System.out.print(b[j]);
            } else {
                System.out.print(" ");
            }
        }

image

@ErSKS ErSKS closed this as completed Aug 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests