请Java高手帮忙  打印五角星

解决方案 »

  1.   

    System.out.println("\u2605");
    System.out.println("\u2730");
      

  2.   

    http://zhidao.baidu.com/question/113001127.html?si=2
      

  3.   

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

  4.   

    http://blog.csdn.net/bao110908/archive/2007/11/27/1904452.aspx
      

  5.   

    像这种控制台绘图,还有这些,有兴趣的话可以参考一下:控制台输出正弦、余弦函数图像:
    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
    #######       # ####### ####### #     # ####### ####### ####### ####### #######
    #     #       #       #       # #     # #       #             # #     # #     #
    #     #       #       #       # #     # #       #             # #     # #     #
    #     #       # ####### ####### ####### ####### #######       # ####### #######
    #     #       # #             #       #       # #     #       # #     #       #
    #     #       # #             #       #       # #     #       # #     #       #
    #######       # ####### #######       # ####### #######       # ####### #######
      

  6.   

    http://www.java3z.com/cwbwebhome/article/article5/5907.html?id=1810看看这个