Skip to content

Instantly share code, notes, and snippets.

@slava-konashkov
Created March 2, 2014 19:46
Show Gist options
  • Select an option

  • Save slava-konashkov/9312708 to your computer and use it in GitHub Desktop.

Select an option

Save slava-konashkov/9312708 to your computer and use it in GitHub Desktop.
Программа рисует снежинку
package cycles;
public class Snowflake {
public static void main(String[] args) {
int iLen = 10;
char[][] arrSnow;
arrSnow = makeSnowflake(iLen);
showSnowflake(arrSnow);
}
private static char[][] makeSnowflake(int iLenght) {
iLenght = ((iLenght >> 1) << 1) + 1;
char[][]snow = new char[iLenght][iLenght];
for (int i = 0; i <snow.length; i++) {
for (int j = 0; j < snow.length; j++) {
snow[i][j] = ' ';
}
}
for (int i=0; i<iLenght; i++) {
snow[i][i] = 'X';
snow[i][iLenght - 1 - i] = 'X';
snow[i][iLenght >>1] = 'X';
snow[iLenght >>1][i] = 'X';
}
return snow;
}
private static void showSnowflake(char[][] snow) {
for (char[] i : snow) {
for (char j : i) {
System.out.print(" " + j + " ");
}
System.out.println("");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment