Tuesday, May 24, 2011

Problem 6 (C++)

#include <iostream>
using namespace ::std;

int main()
{
        int n = 100;
        double a = (2/3.0)*n*n*((n+1)/2.0) + (1/3.0)*n*((n+1)/2.0);
        double b = n*((n+1)/2.0) * n*((n+1)/2.0);
        double x = b - a;

        cout <<int(x);
        cin >> x;//pause
        return 0;
}

2 comments: