求会Java编程的,帮我做个题,帮我编个程序
*
**
***
****
*****
*
**
***
****
*****
public class Test
{
public static void main(String args[])
{
int i=1;
while(i<=5)//while循环生成?和空格
{
System.out.print("?"让橘念);
System.out.print("伍散 "坦困);
int j=1;
while(j<=i)//while循环生成*图形
{
System.out.print("*");
j++;
}
System.out.print("\n");
i++;
}
}
}
这好像是找规律啊,应该两个for就可以了吧,自己多试试就好了
你看看这清手罩个适不适合答闹:
public class 菱形 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
int j;
for (j = 5; j > i; j--) {
System.out.print(" ");
}
for (int k = 1; k <= j; k++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= 5; i++) {
System.out.print("\t");
int j;
for(j = 1; j <= i; j++) {
System.out.print("*"薯隐);
}
System.out.println();
}
}
}