如何開根號 編程實現


public static double sqrt(double a)
{
double x1= 0.0;
double x2 =a/2;

while(x1!=x2)
{
x1=x2;
System.out.println(a/x1);
x2=(x1+a/x1)/2;
}
return x1;
}

6×9的的方格中,起點的左下角,終點在右上角,從起點到終點,只能從下向上,從左向右走,問一共有多少種不同的走法。
A.  4200
B.   5005
C.  1005
D.  以上都不正確

public static int func(int m, int n){

int sum =0;

if(m==0 || n==0){
sum+=1;
}else if(m==1 || n==1){
sum+=m+n;
}else{
for(int i=n;i>=0;i--){
sum+=func(m-1,i);
}
}

return sum;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM