Advertisement
Jvsierra

Project Euler problema 9

Jun 7th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. int main()
  5. {
  6.     int i = 1, j = 1, k = 1, soma, produto;
  7.    
  8.     for(i = 1; i < 1000; i++)
  9.         for(j = 1; j < 1000; j++)
  10.             for(k = 1; k < 1000; k++)
  11.                 if(k * k + j * j == i * i && (i > j && j > k))
  12.                 {
  13.                     if(k + j + i == 1000)
  14.                     {
  15.                         printf("%d ^ 2 + % d ^ 2 = %d ^ 2\n", k, j, i);
  16.                         printf("%d + %d + %d = %d\n", i, j, k, i+j+k);
  17.                         produto = i * j * k;
  18.                         printf("%d\n", produto);
  19.                         break;
  20.                     }
  21.                 }
  22.    
  23.     getch();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement