#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);
}
流程图中是b的平方除以a的平方,你的代码正好是反的啊