/* (Start of program header comment)
* Copyright and version Declaration section of the program
* Copyright (c) 2016, Guangzhou Science and Technology Trade Vocational College, Department of Information Engineering students
* All rights reserved.
* File name: Blue Bridge Cup title
* Author: Pengjunhau
* Completion Date: April 01, 2016
* Version number: 001
* Description part of task and solution method
* Description of the problem:
Xiao Ming designed a cross-shaped logo for an institution (not the Red Cross), as shown below (see p1.jpg)
The other side also needs to be in the Computer DOS window in the form of characters to output the flag, and can control the number of layers.
In order to be able to accurately compare to the number of blanks, the program requires that the whitespace in the line be replaced with a period (.).
* Input Description: standard input and output
* Program output: Please observe the sample carefully, especially pay attention to the number of periods and the output position.
* End of comment on the program head
*/
On the code:
Import Java.util.Scanner;
public class Main {
public static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
int n = sc.nextint ();
int length = 4*n+5;
int ZX = LENGTH/2;
String arr[][] = new String[length][length];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; J < Arr.length; J + +) {
ARR[I][J] = ".";
}
}
for (int i = zx-2; i < zx+3; i++) {
ARR[I][ZX] = "$";
Arr[zx][i] = "$";
}
Control the number of cycles in the outer ring, FOCUS!!!
for (int m = 0; m < n; m++) {
for (int i = zx-(2+m*2); I <= zx+2+2*m; i++) {
arr[zx-(4+m*2)][i] = "$";
Arr[zx+4+m*2][i] = "$";
arr[i][zx-(4+m*2)] = "$";
ARR[I][ZX+4+M*2] = "$";
}
for (int i = 1; I <= zx-(2*m+2); i++) {
arr[zx-(2*m+2)][i] = "$";
Arr[zx+2+2*m][i] = "$";
arr[i][zx-(2*m+2)] = "$";
ARR[I][ZX+2+2*M] = "$";
}
for (int i = zx+2*m+2; I <= arr.length-1; i++) {
Arr[zx+2*m+2][i] = "$";
Arr[zx-2-2*m][i] = "$";
ARR[I][ZX+2*M+2] = "$";
ARR[I][ZX-2-2*M] = "$";
}
Eliminate the excess out of the $
for (int i = zx-m*2; i < zx+m*2; i++) {
arr[zx-(3+m*2)][i] = ".";
arr[zx-(3+m*2)][i] = ".";
Arr[zx+3+m*2][i] = ".";
Arr[zx+3+m*2][i] = ".";
arr[i][zx-(3+m*2)] = ".";
arr[i][zx-(3+m*2)] = ".";
ARR[I][ZX+3+M*2] = ".";
ARR[I][ZX+3+M*2] = ".";
}
}
for (int i = 0; i < arr.length; i++) {
for (int j = 0; J < Arr.length; J + +) {
System.out.print (Arr[i][j]);
}
System.out.println ();
}
}
}
Fourth session Blue Bridge Cup Javac Group _ print Cross chart