From 7b4a3bd091065aa57fb28513dab960ab8c474006 Mon Sep 17 00:00:00 2001 From: Vedansh-Keshari Date: Fri, 8 Oct 2021 16:25:16 +0530 Subject: [PATCH 1/2] Solution for letter N --- Pattern_Printing/N.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Pattern_Printing/N.java diff --git a/Pattern_Printing/N.java b/Pattern_Printing/N.java new file mode 100644 index 0000000..c51d287 --- /dev/null +++ b/Pattern_Printing/N.java @@ -0,0 +1,27 @@ +// Write a program to print letter N exactly +class N{ + public static void main(String args[]){ + + + for(int x=0;x<8;x++){ + for(int y=0;y<13;y++){ + if(y==1 || y==0 || y==11 || y==12){ + System.out.print("#"); + } + else if(y-x==2 || y-x==3){ + System.out.print("@"); + + } + else{ + System.out.print(" "); + + } + } + + System.out.println(); + } + + + + } +} \ No newline at end of file From 9bf3d6faf250f50e441ce0ecfa4e177bfb24a9c1 Mon Sep 17 00:00:00 2001 From: Vedansh Keshari <88903811+Vedansh-Keshari@users.noreply.github.com> Date: Mon, 11 Oct 2021 02:14:25 +0530 Subject: [PATCH 2/2] Update N.java --- Pattern_Printing/N.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Pattern_Printing/N.java b/Pattern_Printing/N.java index c51d287..513c74c 100644 --- a/Pattern_Printing/N.java +++ b/Pattern_Printing/N.java @@ -3,17 +3,22 @@ class N{ public static void main(String args[]){ - for(int x=0;x<8;x++){ - for(int y=0;y<13;y++){ + for(int x=0;x<8;x++){ // to iterate from top to bottom + + for(int y=0;y<13;y++){ // to iterate from left to right in the same row + if(y==1 || y==0 || y==11 || y==12){ - System.out.print("#"); + + System.out.print("#"); // to print hash wherever necessary } else if(y-x==2 || y-x==3){ - System.out.print("@"); + + System.out.print("@"); // to print @ wherever necessary } else{ - System.out.print(" "); + + System.out.print(" "); // to print space wherever necessary } } @@ -24,4 +29,4 @@ else if(y-x==2 || y-x==3){ } -} \ No newline at end of file +}