使用循环语句输出7654321234567输出菱形 50
1个回答
2015-12-09 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
static private String x = "*";
static private String k = " ";
public static void main(String[] args) {
drow(4);
}
public static void drow(int hang) {
for (int i = 1; i <= hang; i++) {
for (int j = 1; j <= hang - i; j++) {
System.out.print(k);
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print(x);
}
System.out.println();
}
for (int i = hang - 1; i >= 1; i--) {
for (int j = 1; j <= hang - i; j++) {
System.out.print(k);
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print(x);
}
System.out.println();
}
}
static private String k = " ";
public static void main(String[] args) {
drow(4);
}
public static void drow(int hang) {
for (int i = 1; i <= hang; i++) {
for (int j = 1; j <= hang - i; j++) {
System.out.print(k);
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print(x);
}
System.out.println();
}
for (int i = hang - 1; i >= 1; i--) {
for (int j = 1; j <= hang - i; j++) {
System.out.print(k);
}
for (int k = 1; k <= 2 * i - 1; k++) {
System.out.print(x);
}
System.out.println();
}
}
追问
用c语言
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询