热度 7||
昨天用java做了个三角形。今天下午老师让我试着做个菱形。看着简单,但是一直出错。弄了两个小时才弄好。呵呵
刚开始接触java真不习惯。呵呵。现在努力学习java中……对了。有人不知道面向对象编程是什么意思,哈哈。
以下是我写的菱形程序。希望大家多提宝贵意见。
class lingxing{
public static void main(String args[]){
for(int q = 0; q <= 4;q++){
for(int z = 4;z>q-1;z--){
System.out.print(" ");
}
for(int a = 0;a<=q;a++){
System.out.print("@ ");
}
System.out.println("");
}
for(int w = 1;w <= 5;w++){
for(int s =0;s<=w;s++){
System.out.print(" ");
}
for(int x =4;x>=w;x--){
System.out.print("@ ");
}
System.out.println("");
}
}
}
图案:
@
@ @
@ @ @
@ @ @ @
@ @ @
@ @
@
手机版|中文乐高 ( 桂ICP备13001575号-7 )
GMT+8, 2025-7-10 01:57 , Processed in 0.067242 second(s), 20 queries .
Powered by Discuz! X3.5
Copyright © 2001-2020, Tencent Cloud.