Thread: Help Newbie

  1. #1
    Unregistered
    Guest

    Help Newbie

    #include<iostream.h>
    //I ONLY NEED THE NUMBERS THAT PROVE TRUE
    //IN COMPUTING PYTHAGOREAN THEORM
    //X^2 + Y^2 = Z^2
    main()
    {
    int z,x,y;


    for (x = 0 ; x <=500;x++)
    for ( y = 0; y <=500; y++)
    for (z = 0; z <=500; z++)

    //I only need the z that proves pythagorean thereom printed
    //HELP ME
    if ((z*z) == (x*x) + (y*y))
    cout<<x<<" + "<<y<<" = "<<z<<"\n";





    return 0;
    }

  2. #2
    Unregistered
    Guest
    The Program is not running properly..its suppossed to output only the possibilities of Z being true which is when x^2 and y^2 are equal to the square of Z...


    Copy and paste the program and run it...
    the output is not correct
    please help me..

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    The program was correct. The output is what confused you

    Code:
    int main()
    { 
    int z,x,y; 
    
    
    for (x = 0; x <=500;x++)
     for ( y = 0; y <=500; y++)
      for (z = 0; z <=500; z++)
       if(z != 0 && x != 0 && y != 0)
        if ((z*z) == ((x*x) + (y*y)) )
         cout<<x<<"^2 + "<<y<<"^2 = "<<z<<"^2   ...because: " << x * x <<" + "<< y * y <<" = "<< z * z <<"\n";
    
    getch();
    getch();
    
    
    
    return 0; 
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    29
    And maybe you don't need three for statements.. only some math
    the numbers
    z=p^2 + q^2
    x = p^2 - q^2
    y = 2*p*q
    are pythagoric for two positive integers p,q (p > q).
    (you can prove it yourself using (a+b)^2 = a^2 + 2*a*b + b^2).
    As far as I know all pythagoric numbers can be written using some p,q but I haven't proved that yet...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM