您的位置:首页 > 其它

打印一个空心菱形

2007-11-24 16:04 357 查看

import java.io.InputStreamReader;








public class Work ...{




public static void main(String[] args) throws IOException ...{


int len; // 菱长


String outstr=new String(); // 输出


int i,j,x,y;


BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


System.out.println("请输入一个菱长:");


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);


}


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: