java:绘制正玄函数和余玄函数[简易版][粗糙版]

  • package 绘制正玄函数;
  • public class Main {
  •     public static void main(String[] args) {
  •         Double m = 0.1;/*表示精确读*/
  •         int n,x;
  •         for(Double y =1.0;y>=0;y-=m)
  •         {
  •             n = (int)(Math.asin(y)*10);
  •             for(x = 0;x<n;x++)
  •                 System.out.print(" ");
  •             System.out.print("*");
  •             for(;x<31-n;x++)
  •                 System.out.print(" ");
  •             System.out.println("*");
  •         }
  •         for(Double y =0.0;y>=-1;y-=m)
  •         {
  •             n = Math.abs((int)(Math.asin(y)*10));
  •             for(x = 0;x<=n+31;x++)
  •                 System.out.print(" ");
  •             System.out.print("*");
  •             for(;x<62-n;x++)
  •                 System.out.print(" ");
  •             System.out.println("*");
  •             
  •         }
  •     }
  • }
  •  

输出样式:

               * *

           *         *

         *             *

       *                 *

      *                   *

     *                     *

    *                       *

   *                         *

  *                           *

 *                             *

*                               *

                                *                              *

                                 *                            *

                                  *                          *

                                   *                        *

                                    *                      *

                                     *                    *

                                      *                  *

                                       *                *

                                         *            *

                                           *        *

                                               **

  • package 绘制余玄函数;
  • public class Main {
  •     public static void main(String[] args) {
  •         // TODO Auto-generated method stub
  •         Double m = 0.1;/*精确度*/
  •         int n,x;
  •         for(Double y = 1.0;y>=-1.0;y-=m)
  •         {
  •             n =Math.abs((int)(Math.acos(y)*10));
  •             for(x =0;x<n;x++)
  •                 System.out.print(" ");
  •             System.out.print("*");
  •             for(;x<62-n;x++)
  •                 System.out.print(" ");
  •             System.out.println("*");    
  •         }
  •     }
  • }

输出样式:

 *                                                              *
    *                                                      *
      *                                                  *
       *                                                *
         *                                            *
          *                                          *
           *                                        *
            *                                      *
             *                                    *
              *                                  *
               *                                *
                *                              *
                 *                            *
                  *                          *
                   *                        *
                    *                      *
                      *                  *
                       *                *
                        *              *
                          *          *
                               **

猜你喜欢

转载自blog.csdn.net/qq_40935723/article/details/82224003