From 82bf37fc096aca55931b6623db13c14218770f85 Mon Sep 17 00:00:00 2001 From: ZubiyaAzeem <146827791+ZubiyaAzeem@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:53:46 +0530 Subject: [PATCH] Added some beginner friendly pattern in java --- different patterns in JAVA/patterns.class | Bin 0 -> 3074 bytes different patterns in JAVA/patterns.java | 224 ++++++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 different patterns in JAVA/patterns.class create mode 100644 different patterns in JAVA/patterns.java diff --git a/different patterns in JAVA/patterns.class b/different patterns in JAVA/patterns.class new file mode 100644 index 0000000000000000000000000000000000000000..65dee137365e5976dbe2d8c3e8714691f0720c5b GIT binary patch literal 3074 zcmb_eU2GIp6#k~2?QWNCX&3spyDbF@wB@IzfCz0VP{g(rBowQW=rZk2+oiiRo82j< zBqoBOG58<^jSwRc68iw8N@7uBAORJFiHR>Jn&`U;A^6&$_}%&0S!f~A__FuToipcr z=R4myckldt?K*(X=D`CiBYcu*jr4BLP1+xiyNCH#93Ilj!2N}yBqq0 z%(Nze1*nx!kyJ+2PF)*RjF;lZ2zMDn(Tt3U)7>yLk`Id*XSEM?T$=q@ie+BZ2hbqA z`%;QwsA-K~&(X$`(bRZaNycLg+o{J?33Genn!0N&IiRNZDgz0gl#J+!g#LOoO=eYX zSR8rkyNOXkQJkPoKyySsi(n*l z7Dd(E`KrU`P<#d6V9^xjPGFAMmT`MDUz&LM6Q8C~aWs$n>mpj78Eq-!fMdZ+aK$LX zBL1#KDc14174xx$@193FR?%u6ybnm+1NLpD-#ZP@G+!2?36UI_`83=tw}lC_H6+K{ zBjNKX%_7NrIPvg4lOTHYP#`rS-M8UMg!i2buMvLwt0BAv91yjrWzxlHMj6*IT3F&$1hCeGPy*RuX&R+g?A6)WhwVzX$Zb|Fm$R0U3#eqk@HJ`z zf)PnFYxakYLe%VM7ll=`R(fh9{p}=X6a9CPns(B$g>`MiYIK@tN+JIRSu%?@jVcRH zOBT+1HWh7F#nxL?)P*DaJ*hL6m=?NXTI^KoH-{bqyYo1(9@4Xe^z>3TJ4wxM&fOg( zs*j@Tp{QOofd!pP6-X7Xmex4PB$a{}MY?Pu+cT?Zc<2d*VB*B-=4QWX6d#j8lrBFWzb z($Mh+QaHx-IG;`;gEL&uVGN(r_7cWTDmS9URh%vQa##CeCwey95IOItpS2F^dGW@rz!SR*n^MpGVNZ&CuTMw6uNaWv&kKs&o~K5Rdzz}SP6AJIU!GY zM0N_29i4Y`bbZs(^?!Cj5#MwZ-^Gy+Tx8;xnD}KTeu;@svY$WWfSJU4T;a&M$WikJ zMLfk0zlwca6?{ecUW38)5WdEneE&9Xn53*g;4xCBQO>dCs?@H#IAq=VpUu8qE|Mm3 z33fZ9b1O$@DB|#uz3J{*6Sa)AxD!=efp}AC literal 0 HcmV?d00001 diff --git a/different patterns in JAVA/patterns.java b/different patterns in JAVA/patterns.java new file mode 100644 index 00000000..8aca7aa6 --- /dev/null +++ b/different patterns in JAVA/patterns.java @@ -0,0 +1,224 @@ +import java.util.*; + +public class patterns{ + +// ****** +// * * +// * * +// * * +// ****** + public static void hollow_rectengle(int row, int col) { + for (int i = 1; i <= row; i++) { + for (int j = 1; j <= col; j++) { + if (i == 1 || i == row || j == 1 || j == col) { + System.out.print("*"); + } + else { + System.out.print(" "); + } + } + System.out.println(); + } + } + +// * +// ** +// *** +// **** +// ***** + public static void inverted_triangle(int row){ + for(int i=1;i<=row;i++){ + for(int j = row-1;j>=i;j--){ + System.out.print(" "); + } + for(int j = 1;j<=i;j++){ + System.out.print("*"); + } + System.out.println(); + } + } + + // 1234 + // 123 + // 12 + // 1 + public static void inverted_halfpyramid_num(int n){ + for(int i =n;i>=1;i--){ + for(int j=1;j<=i;j++){ + System.out.print(j); + } + System.out.println(); + } + } + + // 1 + // 2 3 + // 4 5 6 + // 7 8 9 10 + public static void flyods_triangle(int n){ + int num=1; + for(int i =1;i<=n;i++){ + for(int j=1;j<=i;j++){ + System.out.print(num + " "); + num++; + } + System.out.println(); + } + } + + // 1 + // 01 + // 101 + // 0101 + public static void zero_one_triangle(int n){ + for(int i =1;i<=n;i++){ + for(int j=1;j<=i;j++){ + if((i+j)%2==0){ + System.out.print("1"); + } + else{ + System.out.print("0"); + } + + } System.out.println(); + } + } + // * * + // ** ** + // *** *** + // ******** + // ******** + // *** *** + // ** ** + // * * + public static void butterfly(int n){ + for(int i=1;i<=n;i++){ + for(int j =1;j<=i;j++){ + System.out.print("*"); + } + for(int j=1;j<=2*(n-i);j++){ + System.out.print(" "); + } + for(int j =1;j<=i;j++){ + System.out.print("*"); + } + System.out.println(); + } + for(int i =n;i>=1;i--){ + for(int j =1;j<=i;j++){ + System.out.print("*"); + } + for(int j=1;j<=2*(n-i);j++){ + System.out.print(" "); + } + for(int j =1;j<=i;j++){ + System.out.print("*"); + } + System.out.println(); + + + } + } + +// ***** +// ***** +// ***** +// ***** +// ***** + public static void rohmbus(int n){ + for(int i = 1;i<=n;i++){ + for(int j = 1;j<=n-i;j++){ + System.out.print(" "); + } + for(int j = 1;j<=n;j++){ + System.out.print("*"); + + } + System.out.println(); + } + } +// *** +// * * +// *** + public static void hollow_rohmbus(int n){ + for(int i = 1;i<=n;i++){ + for(int j = 1;j<=n-i;j++){ + System.out.print(" "); + } + for(int j = 1;j<=n;j++){ + if(i==1|| j==1 || i==n || j==n){ + System.out.print("*"); + } + else{ + System.out.print(" "); + } + } + System.out.println(); + } + } + +// * +// *** +// ***** +// ******* +// ********* +// ********* +// ******* +// ***** +// *** +// * + public static void kite(int n){ + for(int i = 1;i<=n;i++){ + for(int j =1;j<=n-i;j++){ + System.out.print(" "); + } + for(int j =1;j<=(2*i)-1;j++){ + System.out.print("*"); + } + System.out.println(); + } + + for(int i = n;i>=1;i--){ + for(int j =1;j<=n-i;j++){ + System.out.print(" "); + } + for(int j =1;j<=(2*i)-1;j++){ + System.out.print("*"); + } + System.out.println(); + } + + } + +// 1 +// 2 2 +// 3 3 3 +// 4 4 4 4 +// 5 5 5 5 5 + public static void num_pyramid(int n){ + int num=1; + for(int i = 1;i<=n;i++){ + for(int j =1;j<=n-i;j++){ + System.out.print(" "); + } + for(int j =1;j<=i;j++){ + System.out.print(num +" "); + } + num++; + System.out.println(); + } + + } + public static void main(String args[]){ + hollow_rectengle(5, 6); + inverted_triangle(5); + inverted_halfpyramid_num(4); + flyods_triangle(4); + zero_one_triangle(4); + butterfly(4); + rohmbus(5); + hollow_rohmbus(3); + kite(5); + num_pyramid(5); + } +} \ No newline at end of file