请大家帮个忙~变革简单的JAVA程序

来源:百度知道 编辑:UC知道 时间:2024/06/06 13:44:18
()()()()*
()()()(***
()()()*****
()()(*******
()()(*******
()()()*****
()()()(***
()()()()* 括号是空格 请问这个怎么做?拜托了~

public class ff {

public static void main(String[] args)

{//打印正三角形*
for(int i=1;i<=7;i=i+2)

{
for(int j=0;j<i;j++)

{System.out.print("*");}

System.out.println();

}
//打印倒三角形*
for(int i=7;i>=1;i=i-2)

{ for(int j=0;j<i;j++)

{System.out.print("*");}

System.out.println();

}

}

}

下面的代码运行即可

package com.test.temp;

public class Test1
{
public static void main(String[] args)
{
Test1 test = new Test1();
test.print(11);
}
public void print(int n)
{
int temp = 0 ;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < Math.abs(n/2-i); j++)
System.out.print(" ");
if(i <= n/2)
temp = i ;
else
temp = n -i - 1;
for(int k = 0; k <(2*tem