http://projecteuler.net/problem=2

来源:互联网 发布:mac的iphoto显示在哪里 编辑:程序博客网 时间:2024/04/28 04:17
#include <iostream>using namespace std;int main(){    int a = 1;    int b = 2;    int c = a + b;    int nSum = 0;    while (b <= 4000000)    {        if (b % 2 == 0)        {            nSum += b;        }        a = b;        b = c;        c = a + b;    }    cout << nSum << endl;    return 0;}

原创粉丝点击