用java程序怎么输出一个圆形?圆形用“*”号打印出来怎么打?
1个回答
展开全部
public class SSS {
public static void main(String[] args) {
int r = 30;
for (int y = 0; y <= 2 * r; y += 2) {
long x = Math.round(r - Math.sqrt(2 * r * y - y * y));
long longLength = 2 * (r - x);
for (int i = 0; i <= x; i++) {
System.out.print(' ');
}
System.out.print('*');
for (int j = 0; j <= longLength; j++) {
System.out.print(' ');
}
System.out.println('*');
}
}
}
public static void main(String[] args) {
int r = 30;
for (int y = 0; y <= 2 * r; y += 2) {
long x = Math.round(r - Math.sqrt(2 * r * y - y * y));
long longLength = 2 * (r - x);
for (int i = 0; i <= x; i++) {
System.out.print(' ');
}
System.out.print('*');
for (int j = 0; j <= longLength; j++) {
System.out.print(' ');
}
System.out.println('*');
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询