这道题用C怎么做
这就是模拟,可以自己尝试敲一下 #include<iostream>#include<cmath>
using namespace std;
int main()
{
int a=1, b=1, n=1;
do
{
b = b+2*a;
a = b-1;
n = n+1;
}
while(!(abs((b*b)/(a*a)-2) < 0.01));
printf("%d", n);
return 0;
}
#include<windows.h>
#include<math.h>
int main()
{
int a=1, b=1, n=1;
do
{
b = b+2*a;
a = b-1;
n = n+1;
}
while(!(abs((b*b)/(a*a)-2) < 0.01));
printf("%d", n);
return 0;
}
页:
[1]