不知道这样的图形怎么用循环打印
     *
   *  *
  *    *
 *      *
*        *
 *      *
  *    *
   *  *
    * 

解决方案 »

  1.   

    import java.util.Scanner;
    class TT{
    public static void main(String[] args){
    System.out.println("请输入你要的级数:");
    Scanner s=new Scanner(System.in);
    int y=s.nextInt();
    print(y);
    }
    public static void print(int line){
    int m=line/2;
    for(int i=0-m;i<=m;i++){
    for(int j=0-m;j<=m;j++){
    System.out.print((Math.abs(i)+Math.abs(j))==m ? "*":" ");
    }
    System.out.println();
    }
    }
    }
      

  2.   

    崩溃!前几天我刚刚回答了这个问题!public class Work {
        public static void main(String[] args) throws IOException {
                System.out.println("请输入一个菱长:");
                int len; // 菱长
                  String outstr=new String(); // 输出
                  int i,j,x,y; 
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String str = br.readLine();
                len=Integer.parseInt(str);             
                for(i=0;i<=len*2;i++){ 
                for(j=0;j<=len*2;j++){ 
                x=len-i; 
                x=x<0?-1*x:x; 
                y=len+(len-x); 
                outstr+=(j==x||j==y?"*":" "); 
                } 
                outstr+=" "; 
                } 
                System.out.println(outstr); 
                }