Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ccc01j1 {
- public static void main(String[] args) {
- //https://dmoj.ca/problem/ccc01j1
- // input N as int
- // output N *
- Scanner sc = new Scanner(System.in);
- int N = sc.nextInt();
- for (int c=1; c<=N; c=c+2) {
- //c stars
- for (int i=0; i<c; i++) {
- System.out.print("*");
- }
- //2*N-2*c spaces
- for (int i=0; i<2*N-2*c; i++) {
- System.out.print(" ");
- }
- //c stars
- for (int i=0; i<c; i++) {
- System.out.print("*");
- }
- System.out.println();
- }
- for (int c=N-2; c>=1; c=c-2) {
- //c stars
- for (int i=0; i<c; i++) {
- System.out.print("*");
- }
- //2*N-2*c spaces
- for (int i=0; i<2*N-2*c; i++) {
- System.out.print(" ");
- }
- //c stars
- for (int i=0; i<c; i++) {
- System.out.print("*");
- }
- System.out.println();
- }
- }
- // * * 1 8 1 2*5-1*2
- // *** *** 3 4 3 2*5-3*2
- // ********** 5 0 5 2*5-5*2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement