Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long int a = 0;
- cout<<"The triplets of a triangle with maximum side length 500 are: \n";
- cout<<"Side 1\t Side 2\t hypotaneous";
- for(long int side_one=1;side_one<=500;side_one++)
- {
- for(long int side_two=1;side_two<=500;side_two++)
- {
- for(long int hypotaneous=1;hypotaneous<=500;hypotaneous++)
- {
- while(((hypotaneous*hypotaneous) == ((side_one*side_one)+(side_two*side_two))) && (side_one > side_two))
- {
- cout<<side_one<<"\t"<<side_two<<"\t"<<hypotaneous<<endl;
- a++;
- break;
- }
- }
- }
- }
- cout<<"There are "<<a<<" triplets"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement