问题遇到的现象和发生背景 我想写一个循环语句但是得不到想要的结果。
问题相关代码,请勿粘贴截图
#include <stdio.h>
#include <math.h>
int main() {
int a, b, n=1.0;
a=1.0;
b=1.0;
while(fabs(pow(b, 2)/pow(a, 2)-2)<0.01) {
b=b+2*a;
a=b-a;
n=n+1;
}
printf("n=%d\n", n);
}