Advertisement
Guest User

Untitled

a guest
May 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ccc01j1 {
  4. public static void main(String[] args) {
  5. //https://dmoj.ca/problem/ccc01j1
  6. // input N as int
  7. // output N *
  8. Scanner sc = new Scanner(System.in);
  9. int N = sc.nextInt();
  10. for (int c=1; c<=N; c=c+2) {
  11. //c stars
  12. for (int i=0; i<c; i++) {
  13. System.out.print("*");
  14. }
  15. //2*N-2*c spaces
  16. for (int i=0; i<2*N-2*c; i++) {
  17. System.out.print(" ");
  18. }
  19. //c stars
  20. for (int i=0; i<c; i++) {
  21. System.out.print("*");
  22. }
  23. System.out.println();
  24. }
  25. for (int c=N-2; c>=1; c=c-2) {
  26. //c stars
  27. for (int i=0; i<c; i++) {
  28. System.out.print("*");
  29. }
  30. //2*N-2*c spaces
  31. for (int i=0; i<2*N-2*c; i++) {
  32. System.out.print(" ");
  33. }
  34. //c stars
  35. for (int i=0; i<c; i++) {
  36. System.out.print("*");
  37. }
  38. System.out.println();
  39. }
  40. }
  41. // * * 1 8 1 2*5-1*2
  42. // *** *** 3 4 3 2*5-3*2
  43. // ********** 5 0 5 2*5-5*2
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement