Created
January 15, 2016 17:26
-
-
Save Jack-Saleem/a1885725e5b651223a96 to your computer and use it in GitHub Desktop.
Codeforces 454A LittlePonyandCrystalMine program in java
This file contains hidden or 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
import java.util.Scanner; | |
public class LittlePonyandCrystalMine | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner z=new Scanner(System.in); | |
int n=z.nextInt(); | |
StringBuilder sb=new StringBuilder(); | |
String x[]=new String[n]; | |
for(int i=1;i<=(n/2)+1;i++) | |
{ | |
sb.setLength(0); | |
for(int j=1;j<=n;j++) | |
{ | |
if(i<(n/2)+1) | |
{ | |
if(i==1){ | |
if(j==(n/2)+1){ | |
System.out.print("D"); | |
sb.append("D"); | |
} | |
else { | |
System.out.print("*"); | |
sb.append("*"); | |
} | |
} else { | |
if(j>=(n/2)+1-(i-1) && j<=(n/2)+1+(i-1)){ | |
System.out.print("D"); | |
sb.append("D"); | |
} | |
else { | |
System.out.print("*"); | |
sb.append("*"); | |
} | |
} | |
x[i]=sb.toString(); | |
} | |
else | |
System.out.print("D"); | |
} | |
System.out.println(); | |
} | |
for(int k=(n/2);k>0;k--) | |
System.out.println(x[k]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment