| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + /* For n =4 the output should be | ||
| 2 | + | ||
| 3 | + * | ||
| 4 | + * * | ||
| 5 | + * * * | ||
| 6 | + * * * * | ||
| 7 | + * * * | ||
| 8 | + * * | ||
| 9 | + * | ||
| 10 | + | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | + import java.util.Scanner; | ||
| 14 | + | ||
| 15 | + public class Solution { | ||
| 16 | + | ||
| 17 | + public static void main(String[] args) { | ||
| 18 | + Scanner s = new Scanner(System.in); | ||
| 19 | + int n = s.nextInt(); | ||
| 20 | + for (int i = 1; i <= n; i++) { | ||
| 21 | + for (int stars = 1; stars <= i; stars++) { | ||
| 22 | + System.out.print("* "); | ||
| 23 | + } | ||
| 24 | + System.out.println(); | ||
| 25 | + } | ||
| 26 | + for (int i = 1; i < n; i++) { | ||
| 27 | + for (int stars = n - 1; stars >= i; stars--) { | ||
| 28 | + System.out.print("* "); | ||
| 29 | + } | ||
| 30 | + System.out.println(); | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments