#include<stdio.h> int main() { int i = 1; int j = 2; float sum = 0; float k = 0; int t, n = 0; k = j / i; sum = k; for (n = 2; n < 20; n++) { t = i; i = j; j = t + i; k = j / i; sum = sum + k; } printf("sum=%lf\n", sum); system("pause"); return 0; }
结果:
sum=20