Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  degen
Language: C/C++
Code:
using namespace std;

#include <iostream>
#include <string>
#include <math.h>

bool isint(float n)
{
    int l=(int)(n);
    if((n-l)==0)
        return true;
    else
        return false;
}

void degen(int m)
{
    for(int i = 3; i < m; i++)
    {
        if(isint(sqrt(m*m - i*i)))
        {
            cout<<m<<"^2 = "<<i<<"^2 + "<<sqrt(m*m - i*i)<<"^2\n";
        }
    }
}

int main()
{
    float j,m;
    int s=1;
    for(m=5;m<10000;m++)
    {
        for(int k=3;k < m; k++)
        {
            if(isint(sqrt(m*m - k*k)))
            {
                for(j=k+1;j<m;j++)
                {
                    if(isint(sqrt(m*m - j*j))&&(j!=sqrt(m*m - k*k)))
                    {
                        cout<<s<<")\n";
                        degen((int)(m));
                        s++;
                        k = (int)(m) + 1;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}
Comments: