-
Notifications
You must be signed in to change notification settings - Fork 153
Added my day 5 code in Java #361
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Open
shashwatgupta24
wants to merge
7
commits into
CodeToExpress:master
Choose a base branch
from
shashwatgupta24:Day_5
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5bc98bb
Added my day 5 code in Java
shashwatgupta24 0d03a86
Update Pattern__1.java
shashwatgupta24 1a15adb
Update Pattern__2.java
shashwatgupta24 58ca360
Update Pattern__3.java
shashwatgupta24 58c6ddd
Update Pattern__4.java
shashwatgupta24 2bdd8b6
Update Pattern__5.java
shashwatgupta24 b81b6d8
Update README.md
shashwatgupta24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(" "); | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(""); | ||
|
||
|
||
|
||
} | ||
|
||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||||||||
} | ||||||||
|
||||||||
} | ||||||||
|
||||||||
} | ||||||||
|
||||||||
``` | ||||||||
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? | ||||||||
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) :) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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