?? pi.java
字號:
package mypackage;public class Pi { public static void main(String[] args) { int ARRSIZE=103, DISPCNT=100; //定義數組大小,顯示位數 int [] x= new int [ARRSIZE];//x[0] x[1] . x[2] x[3] x[4] .... x[ARRSIZE-1] int [] z = new int [ARRSIZE]; int a=1, b=3, c, d, Cnt=0; x[1] = 2; z[1] = 2; while( (++Cnt<20000)) { d = 0; for(int i=ARRSIZE-1; i>0; i--)//z*=a; { c = z[i]*a + d; z[i] = c%10; d = c / 10; } d = 0; for(int i=0; i<ARRSIZE; i++)//z/=b; { c = z[i]+d*10; z[i] = c/b; d = c % b; } for(int i=ARRSIZE-1; i>0; i--)//x+=z; { c = x[i] + z[i]; x[i] = c%10; x[i-1] += c/10; } a++; b+=2; }System.out .print("pi="+x[0]+(x[1])+".") ; for(int i=0; i<DISPCNT; i++) { if ((i%100)==0){System.out.println() ;}if(i>4&&i%5==0){System.out.print(",") ;} System.out.print(x[i+2]) ; }}}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -