Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. long int a = 0;
  8.  
  9. cout<<"The triplets of a triangle with maximum side length 500 are: \n";
  10. cout<<"Side 1\t Side 2\t hypotaneous";
  11. for(long int side_one=1;side_one<=500;side_one++)
  12. {
  13. for(long int side_two=1;side_two<=500;side_two++)
  14. {
  15. for(long int hypotaneous=1;hypotaneous<=500;hypotaneous++)
  16. {
  17. while(((hypotaneous*hypotaneous) == ((side_one*side_one)+(side_two*side_two))) && (side_one > side_two))
  18. {
  19. cout<<side_one<<"\t"<<side_two<<"\t"<<hypotaneous<<endl;
  20. a++;
  21. break;
  22. }
  23. }
  24. }
  25. }
  26. cout<<"There are "<<a<<" triplets"<<endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement