Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 149
Added my day 5 code in Java#361
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
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
5bc98bb0d03a861a15adb58ca36058c6ddd2bdd8b6b81b6d8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* @date 14/10/2020 | ||
| * @author Shashwat Gupta (shashwatxdevelop) | ||
| */ | ||
| import java.util.Scanner; | ||
| public class Pattern__1 { | ||
| public static void main(String[] args) { | ||
| int i,j,n; | ||
| Scanner sc = new Scanner (System.in); | ||
| n= sc.nextInt(); | ||
| for(i=1; i<=n; i++) | ||
| { | ||
| for (j=1; j<=i;j++) | ||
| { | ||
| System.out.print(j+" "); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* @date 14/10/2020 | ||
| * @author Shashwat Gupta (shashwatxdevelop) | ||
| */ | ||
| import java.util.Scanner; | ||
| public class Pattern__2 { | ||
| public static void main(String[] args) { | ||
| int i,j,n, s=0; | ||
| Scanner sc = new Scanner (System.in); | ||
| n= sc.nextInt(); | ||
| for (i=1; i<=n; i++) | ||
| { | ||
| for (j=1; j<=i; j++) | ||
| { | ||
| s=s+1; | ||
| System.out.print(s+" "); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* @date 14/10/2020 | ||
| * @author Shashwat Gupta (shashwatxdevelop) | ||
| */ | ||
| import java.util.Scanner; | ||
| public class Pattern__3 { | ||
| public static void main(String[] args) { | ||
| int i,j,n,a,b; | ||
| Scanner sc = new Scanner (System.in); | ||
| n= sc.nextInt(); | ||
| for(i=1; i<=n; i++) | ||
| { | ||
| for(j=1; j<=i; j++) | ||
| { | ||
| System.out.print(j+" "); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| for (i=n-1; i>=1; i--) | ||
| { | ||
| for (j=1; j<=i; j++ ) | ||
| { | ||
| System.out.print(j+" "); | ||
| } | ||
| System.out.println(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* @date 14/10/2020 | ||
| * @author Shashwat Gupta (shashwatxdevelop) | ||
| */ | ||
| import java.util.Scanner; | ||
| public class Pattern__4 { | ||
| public static void main(String[] args) { | ||
| int i,j,n; | ||
| Scanner sc =new Scanner (System.in); | ||
| n= sc.nextInt(); | ||
| for (i=1; i<=n; i++) | ||
| { | ||
| for (j=n; j>i; j--) | ||
| { | ||
| System.out.print(" "); | ||
| } | ||
| for (j=i; j<=(2*i-1); j++) | ||
| { | ||
| System.out.print(j+" "); | ||
| } | ||
| for (j=(2*i-1) - 1; j>=i; j--) | ||
| { | ||
| System.out.print(j+" "); | ||
| } | ||
| System.out.println(" "); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* @date 14/10/2020 | ||
| * @author Shashwat Gupta (shashwatxdevelop) | ||
| */ | ||
| import java.util.Scanner; | ||
| public class Pattern__5 { | ||
| public static void main(String[] args) { | ||
| int i,j,k,n, p=1; | ||
| Scanner sc = new Scanner (System.in); | ||
| n= sc.nextInt(); | ||
| for(i=1; i<=n;i++) | ||
| { | ||
| for (j=1; j<i; j++) | ||
| { | ||
| System.out.print(" "); | ||
| } | ||
| for (j=1; j<= (2*n-(2*i-1)); j++) | ||
| { | ||
| System.out.print("*"); | ||
| } | ||
| System.out.println(""); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -2157,10 +2157,156 @@ int main() { | ||||||||
| eighth_pattern(num); | ||||||||
| return 0; | ||||||||
| } | ||||||||
| ``` | ||||||||
| /* @date 14/10/2020 | ||||||||
| * @author Shashwat Gupta (shashwatxdevelop) | ||||||||
| */ | ||||||||
| import java.util.Scanner; | ||||||||
| public class Pattern__1 { | ||||||||
| public static void main(String[] args) { | ||||||||
| int i,j,n; | ||||||||
| Scanner sc = new Scanner (System.in); | ||||||||
| n= sc.nextInt(); | ||||||||
| for(i=1; i<=n; i++) | ||||||||
| { | ||||||||
| for (j=1; j<=i;j++) | ||||||||
| { | ||||||||
| System.out.print(j+" "); | ||||||||
| } | ||||||||
| System.out.println(); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| ``` | ||||||||
| /* @date 14/10/2020 | ||||||||
| * @author Shashwat Gupta (shashwatxdevelop) | ||||||||
| */ | ||||||||
| import java.util.Scanner; | ||||||||
| public class Pattern__2 { | ||||||||
| public static void main(String[] args) { | ||||||||
| int i,j,n, s=0; | ||||||||
| Scanner sc = new Scanner (System.in); | ||||||||
| n= sc.nextInt(); | ||||||||
| for (i=1; i<=n; i++) | ||||||||
| { | ||||||||
| for (j=1; j<=i; j++) | ||||||||
| { | ||||||||
| s=s+1; | ||||||||
| System.out.print(s+" "); | ||||||||
| } | ||||||||
| System.out.println(); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| ``` | ||||||||
| /* @date 14/10/2020 | ||||||||
| * @author Shashwat Gupta (shashwatxdevelop) | ||||||||
| */ | ||||||||
| import java.util.Scanner; | ||||||||
| public class Pattern__3 { | ||||||||
| public static void main(String[] args) { | ||||||||
| int i,j,n,a,b; | ||||||||
| Scanner sc = new Scanner (System.in); | ||||||||
| n= sc.nextInt(); | ||||||||
| for(i=1; i<=n; i++) | ||||||||
| { | ||||||||
| for(j=1; j<=i; j++) | ||||||||
| { | ||||||||
| System.out.print(j+" "); | ||||||||
| } | ||||||||
| System.out.println(); | ||||||||
| } | ||||||||
| for (i=n-1; i>=1; i--) | ||||||||
| { | ||||||||
| for (j=1; j<=i; j++ ) | ||||||||
| { | ||||||||
| System.out.print(j+" "); | ||||||||
| } | ||||||||
| System.out.println(); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| ``` | ||||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same changes here | ||||||||
| /* @date 14/10/2020 | ||||||||
| * @author Shashwat Gupta (shashwatxdevelop) | ||||||||
| */ | ||||||||
| import java.util.Scanner; | ||||||||
| public class Pattern__4 { | ||||||||
| public static void main(String[] args) { | ||||||||
| int i,j,n; | ||||||||
| Scanner sc =new Scanner (System.in); | ||||||||
| n= sc.nextInt(); | ||||||||
| for (i=1; i<=n; i++) | ||||||||
| { | ||||||||
| for (j=n; j>i; j--) | ||||||||
| { | ||||||||
| System.out.print(" "); | ||||||||
| } | ||||||||
| for (j=i; j<=(2*i-1); j++) | ||||||||
| { | ||||||||
| System.out.print(j+" "); | ||||||||
| } | ||||||||
| for (j=(2*i-1) - 1; j>=i; j--) | ||||||||
| { | ||||||||
| System.out.print(j+" "); | ||||||||
| } | ||||||||
| System.out.println(" "); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| ``` | ||||||||
| /* @date 14/10/2020 | ||||||||
| * @author Shashwat Gupta (shashwatxdevelop) | ||||||||
| */ | ||||||||
| import java.util.Scanner; | ||||||||
| public class Pattern__5 { | ||||||||
| public static void main(String[] args) { | ||||||||
| int i,j,k,n, p=1; | ||||||||
| Scanner sc = new Scanner (System.in); | ||||||||
| n= sc.nextInt(); | ||||||||
| for(i=1; i<=n;i++) | ||||||||
| { | ||||||||
| for (j=1; j<i; j++) | ||||||||
| { | ||||||||
| System.out.print(" "); | ||||||||
| } | ||||||||
| for (j=1; j<= (2*n-(2*i-1)); j++) | ||||||||
| { | ||||||||
| System.out.print("*"); | ||||||||
| } | ||||||||
| System.out.println(""); | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| ``` | ||||||||
| ### Have Another solution? | ||||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ||||||||
| The beauty of programming lies in the fact that there is never a single solution to any problem. | ||||||||
| In case you have an alternative way to solve this problem, do contribute to this repository (https://github.com/CodeToExpress/dailycodebase) :) | ||||||||
| In case you have an alternative way to solve this problem, do contribute to this repository (https://github.com/CodeToExpress/dailycodebase) :) | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also