PLEASE HELP

PLEASE HELP

Post by Fondue19 » Fri, 07 Mar 1997 04:00:00



Please help me by sending me the code for this C++ program. It is for a
unix system. It is for my intro Computer Science class. It is from the
Deitel book, "How to program C++." Thanks.

2.55    (Pythagorean Triples) A right triangle can have sides that are all
integers.  The set of three integer values for the sides of a right
triangle is called a Pythagorean triple.  These three sides must satisfy
the relationship that the sum of the squares of two of the sides is equal
to the square of the hypotenuse.  Find all Pythagorean triples for side l,
side2, and the hypotenuse all no larger than 500.  Use a triple-nested
for-loop that tries all possibilities.  This is an example of "brute
force" computing.  You will learn in more advanced computer science
courses that there are large numbers of interesting problems for which
there is no known algorithmic approach other than using sheer brute force.

 
 
 

PLEASE HELP

Post by Enrique Avile » Fri, 07 Mar 1997 04:00:00



> Please help me by sending me the code for this C++ program. It is for a
> unix system. It is for my intro Computer Science class. It is from the
> Deitel book, "How to program C++." Thanks.

> 2.55    (Pythagorean Triples) A right triangle can have sides that are all
> integers.  The set of three integer values for the sides of a right
> triangle is called a Pythagorean triple.  These three sides must satisfy
> the relationship that the sum of the squares of two of the sides is equal
> to the square of the hypotenuse.  Find all Pythagorean triples for side l,
> side2, and the hypotenuse all no larger than 500.  Use a triple-nested
> for-loop that tries all possibilities.  This is an example of "brute
> force" computing.  You will learn in more advanced computer science
> courses that there are large numbers of interesting problems for which
> there is no known algorithmic approach other than using sheer brute force.

In good old C this would be:

#include <stdio.h>
main()
{
   long int a,b,c;

   for (a=1; a<=500; a++)
   {
      for (b=1; b<=500; b++)
          {
             for (c=1; c<=500; c++)
                 {
                    if( (a*a + b*b) == c*c)
                        {
                           printf("a: %d b:%d c:%d\n",a,b,c);
                        }
                 }
          }
   }
   return(0);

Quote:}

-Enrique

 
 
 

1. PLEASE PLEASE HELP Major problem with my SCSI & Redhat 5.0 PLEASE Help

Everything ran WONDERFUL for about 4 months this machine ran several
servers it is a UDB w/ 340mb SCSI (SLOW 5mb) half inch internal hard
drive.  32 megs of true parity ram, Red hat 5.0 I get the following
error

NCR53-810-0: ERROR (0:48) (0-20-0) (8/33) * scripth (868:18000400).
NCR53-810-0: Script cmd = 888030000
NCR53-810-0: regdump : da 10 80 33 47 08 00 1f 01 08 00 28 80 00 08 00
NCR53-810-0: have to clear fifos

What the HELL is this and is there anyway to fix it ?  It seems to
occur when doing file writing, when i try to tar something for example
it will go into a continual unending loop displaying the above error
message.  I have refdisked, formated, and clean installed redhat and
the problem is still there :( Please help, if at all possible mail

2. Installing Linux via NFS

3. LINUX instalation problems, PLEASE HELP !?!Subject: LINUX , instalation problems, PLEASE HELP !?!

4. kmix displays wrong soundcard name

5. PLEASE HELP !!! PLEASE HELP !!!

6. Bootx - can′t get it running

7. Sendmail problems. Please please please please help!

8. /etc/rc.d/rc.inet1 can't fork.

9. NFS please help me please please please sniff

10. Set-up woes, please, please, please help :(

11. please please please help me!

12. Please Please Please HELP