http://www.
黄金分割比太简单了。随便一个link都有很详细的说明。
黄金分割比太简单了。随便一个link都有很详细的说明。
程序代码:int Test2(int a)
{
double x, y, sf;
int n, t;
x = log(SQRT_5 * a) / log(A);
x += 0.5;
n = (int)x;
y = (pow(A, n) - pow(B, n)) / SQRT_5;
y += 0.5;
t = (int)y;
if(t > a) n--;
n -= n % 3;
sf = ((SQRT_5 + 1) / (SQRT_5 - 1) * (pow(A, n) - 1) - (1 - SQRT_5) / (1 + SQRT_5) * (1 - pow(B, n))) / SQRT_5;
sf += 0.5;
return ((int)sf) / 2;
}

程序代码:1.
# include<stdio.h>
int main(void)
{
int i = 0;
int j = 0;
for(i = 0; i < 1000; i++)
{
if(i%3 == 0 || i%5 == 0)
j = j + i;
}
printf("%d\n", j);
return 0;
}
2.
int main(void)
{
int a = 1;
int b = 0;
int c = 0;
int d = 0;
for(; ;)
{
c = a + b;
a = b;
b = c;
if(c%2 == 0)
d = d + c;
if(c > 4000000)
break;
}
printf("%d\n", d);
return 0;
}
第三题不懂