请高手帮忙 打印五角星 请Java高手帮忙 打印五角星 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 System.out.println("\u2605");System.out.println("\u2730"); http://zhidao.baidu.com/question/113001127.html?si=2 Test1.javaimport java.awt.*; import javax.swing.*; public class Test1 extends JPanel { private JFrame frame = null; private int r = 50; // 半径 private int[] x = new int[5]; // 5个X轴顶点坐标 private int[] y = new int[5]; // 5个Y轴顶点坐标 public Test1() { this.math(); frame = new JFrame("五角星"); frame.getContentPane().add(this); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 200); frame.setVisible(true); } private void math() { int c = 360 / 5; // 角度 for (int i = 0; i < 5; i++) { x[i] = (int) (Math.cos(i * c * Math.PI / 30 - Math.PI / 2) * (r) + r); y[i] = (int) (Math.sin(i * c * Math.PI / 30 - Math.PI / 2) * (r) + r); } } public void paint(Graphics g) { super.paint(g); g.drawLine(x[0], y[0], x[2], y[2]); g.drawLine(x[0], y[0], x[3], y[3]); g.drawLine(x[1], y[1], x[3], y[3]); g.drawLine(x[1], y[1], x[4], y[4]); g.drawLine(x[2], y[2], x[4], y[4]); g.drawLine(x[2], y[2], x[0], y[0]); } public static void main(String[] args) { new Test1(); } } http://blog.csdn.net/bao110908/archive/2007/11/27/1904452.aspx 像这种控制台绘图,还有这些,有兴趣的话可以参考一下:控制台输出正弦、余弦函数图像:http://topic.csdn.net/u/20071221/12/6fde1214-f20c-42ba-a343-a2511c05b485.html #### | #### ## ## | ## ## # # | # # # # | # # # # | # # # # | # # # # | # # | # # | # # # # | # # # # |# # | #------------------------#------------------------#------------------------#------------------------# | # #| # # # # | # # # # | # # | # # | # # # # | # # # # | # # # # | # # # # | # # ## ## | ## ## #### | #### ### ##### ### ## ## | ## ## # # | # # # # | # # # # | # # | # # | # # # # | # # # # | # # | # # | # # # # | # # --------------------------------------------------+-------------------------------------------------- # # | # # # # | # # | # # | # # # # | # # # # | # # | # # | # # # # | # # # # | # # ## ## | ## ## ##### | ##### 控制台输出七段 LED 数字:http://topic.csdn.net/u/20080818/21/e77f9240-a491-43da-96b6-18f1be97eda2.html####### # ####### ####### # # ####### ####### ####### ####### ######## # # # # # # # # # # # # ## # # # # # # # # # # # # ## # # ####### ####### ####### ####### ####### # ####### ######## # # # # # # # # # # # ## # # # # # # # # # # # ######## # ####### ####### # ####### ####### # ####### ####### http://www.java3z.com/cwbwebhome/article/article5/5907.html?id=1810看看这个 Date相加问题 repaint()方法不自动调用update()方法(急 在线等) 新手弱问,模式对话框里不能进行数据库操作? ▲★数据集 排序问题★▲ 一时糊涂,问个基础问题:System.out.print() 如何执行?在Panel面板中 菜鸟问题 这个问题困扰我3个月了,就是无法解决,谁如果能帮我,我将追加500分!!!!!!!!!! 事件处理的问题 Apusic2.0在官方网上无法下载??? 急求答案 求一个两数组里的元素是否相同的比较算法,在线等达人,谢谢啦~~
System.out.println("\u2730");
import javax.swing.*;
public class Test1 extends JPanel {
private JFrame frame = null;
private int r = 50; // 半径
private int[] x = new int[5]; // 5个X轴顶点坐标
private int[] y = new int[5]; // 5个Y轴顶点坐标
public Test1() {
this.math();
frame = new JFrame("五角星");
frame.getContentPane().add(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setVisible(true);
}
private void math() {
int c = 360 / 5; // 角度
for (int i = 0; i < 5; i++) {
x[i] = (int) (Math.cos(i * c * Math.PI / 30 - Math.PI / 2) * (r) + r);
y[i] = (int) (Math.sin(i * c * Math.PI / 30 - Math.PI / 2) * (r) + r);
}
}
public void paint(Graphics g) {
super.paint(g);
g.drawLine(x[0], y[0], x[2], y[2]);
g.drawLine(x[0], y[0], x[3], y[3]);
g.drawLine(x[1], y[1], x[3], y[3]);
g.drawLine(x[1], y[1], x[4], y[4]);
g.drawLine(x[2], y[2], x[4], y[4]);
g.drawLine(x[2], y[2], x[0], y[0]);
}
public static void main(String[] args) {
new Test1();
}
}
http://topic.csdn.net/u/20071221/12/6fde1214-f20c-42ba-a343-a2511c05b485.html
#### | ####
## ## | ## ##
# # | # #
# # | # #
# # | # #
# # | # #
# # | # #
|
# # | # #
# # | # #
# # |# #
|
#------------------------#------------------------#------------------------#------------------------#
|
# #| # #
# # | # #
# # | # #
|
# # | # #
# # | # #
# # | # #
# # | # #
# # | # #
## ## | ## ##
#### | ####
### ##### ###
## ## | ## ##
# # | # #
# # | # #
# # | # #
|
# # | # #
# # | # #
# # | # #
|
# # | # #
# # | # #
--------------------------------------------------+--------------------------------------------------
# # | # #
# # | # #
|
# # | # #
# # | # #
# # | # #
|
# # | # #
# # | # #
# # | # #
## ## | ## ##
##### | #####
控制台输出七段 LED 数字:
http://topic.csdn.net/u/20080818/21/e77f9240-a491-43da-96b6-18f1be97eda2.html
####### # ####### ####### # # ####### ####### ####### ####### #######
# # # # # # # # # # # # # #
# # # # # # # # # # # # # #
# # # ####### ####### ####### ####### ####### # ####### #######
# # # # # # # # # # # # #
# # # # # # # # # # # # #
####### # ####### ####### # ####### ####### # ####### #######