Date created: 07/10/11 19:19:32. Last modified: 12/13/12 11:41:20

Problem 9

// Project Euler - Problem 9
#include <stdlib.h>
#include <stdio.h>

int main (int argc, char *argv[]) {

        int a, b, c;
        int top=500;

        for(a=1;a<=top;a++) {
                for(b=1;b<=top;b++) {
                        for(c=1;c<=top;c++) {
                                if (a<b) {
                                        if(b<c) {
                                                if((a*a)+(b*b)==(c*c)) {
                                                        if(a+b+c==1000) {
                                                                printf("a= %d b= %d c= %d; a*b*c= %d\n", a, b, c, (a*b*c));
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }
        return EXIT_SUCCESS;
}

Previous page: Problem 8
Next page: Problem 10