题解 | #牛牛的字符菱形#
牛牛的字符菱形
https://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8
坐标轴
import java.util.Scanner;
public class Main {public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String str = s.next();
for (int x = -5 / 2; x <= 5 / 2; x++) {
for (int y = -5 / 2; y <= 5 / 2; y++) {
if ((x > 0 ? x : -x) + (y > 0 ? y : -y) <= 5 / 2) {
System.out.print(str);
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
#猹的刷题生涯#