GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


problem by baldurk
1
 
#include <iostream>
using namespace std;

int main()
{
    for(int i=1; i <= 36; i++)
        for(int j=i; j <= 36; j++)
            for(int k=j; k <= 36; k++)
                if(i*j*k==36)cout << i << " + " << j << " + " << k << " = " << i+j+k << endl;
    return 0;
}

/* output:

$ ./foo 
1 + 1 + 36 = 38
1 + 2 + 18 = 21
1 + 3 + 12 = 16
1 + 4 + 9 = 14
1 + 6 + 6 = 13
2 + 2 + 9 = 13
2 + 3 + 6 = 11
3 + 3 + 4 = 10

*/