C++ Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soccr743
    FFR Player
    • Dec 2003
    • 549

    #31
    RE: Re: RE: Re: C++ Help

    You messed up your logic for the x and y axis stuff...

    Should be:

    input x, input y
    if x==0 and y==0
    then output "origin"
    else if x==0 and y!=0
    then output "y-axis"
    else if y==0 and x!=0
    then output "x-axis"
    else if x > 0 and y > 0
    then output "first quadrant"
    else if x < 0 and y > 0
    then output "second quadrant"
    else if x<0 and y<0
    then output "third quadrant"
    else if x>0 and y<0 then output "fourth quadrant"

    That is far from tedious as far as code goes...

    -----Soccr743-----

    Comment

    • talisman
      Resident Penguin
      FFR Simfile Author
      • May 2003
      • 4598

      #32
      RE: Re: RE: Re: C++ Help

      oh yeah. ::

      Comment

      • chickendude
        Away from Computer
        FFR Simfile Author
        • Sep 2003
        • 1901

        #33
        RE: Re: RE: Re: C++ Help

        Code:
        #include <iostream>
        main&#40;&#41;
        &#123;
         int x,y;
        
         cout << "enter an x and a y";
         cin >> x;
         cin >> y;
         if x==0 && y==0
            cout << "origin";
         if x==0 && y!=0
            cout << "y-axis";
         if y==0 && x!=0
            cout << "x-axis";
         if x > 0 && y > 0
            cout << "first quadrant";
         if x < 0 && y > 0
            cout << "second quadrant";
         if x<0 && y<0
            cout << "third quadrant";
         if x>0 && y<0 
            cout << "fourth quadrant" ;
        &#125;
        did I win?


        Edit for bad include syntax <_<

        Comment

        • talisman
          Resident Penguin
          FFR Simfile Author
          • May 2003
          • 4598

          #34
          RE: Re: RE: Re: C++ Help

          you forgot the most important part.

          I'll let you try to figure out where it is...

          Comment

          • QreepyBORIS
            FFR Player
            • Feb 2003
            • 7454

            #35
            RE: Re: RE: Re: C++ Help

            Gosh, I can't figure it out, Talis (or can I?).

            If you read that sentence above and you have a brain, you'd know I know what the errors would be.

            Oh, snap, I read the code again and there's actually another, much more glaring error in Nipunn's code. How could you, man? I always add that in first.

            Also, you should declare a namespace. It's a good practice.


            Also, you should make x and y doubles, then ask for their input on the same line (as in, cin >> x >> y. You just need a space between the two numbers when you input them.

            Also, you should use newlines and grammar to spice it up.

            Signature subject to change.

            THE ZERRRRRG.

            Comment

            • chickendude
              Away from Computer
              FFR Simfile Author
              • Sep 2003
              • 1901

              #36
              Re: RE: Re: RE: Re: C++ Help

              Code:
              #include <iostream>
              main&#40;&#41;
              &#123;
               using std&#58;&#58;namespace
               int x,y;
              
               cout << "enter an x and a y";
               cin >> x >> y;
               if x==0 && y==0
                  cout << "origin";
               if x==0 && y!=0
                  cout << "y-axis";
               if y==0 && x!=0
                  cout << "x-axis";
               if x > 0 && y > 0
                  cout << "first quadrant";
               if x < 0 && y > 0
                  cout << "second quadrant";
               if x<0 && y<0
                  cout << "third quadrant";
               if x>0 && y<0 
                  cout << "fourth quadrant" ;
              &#125;
              ok std::namespace
              and cin both on the same line
              I stole all the words from talisman/sccr
              plus I forget how to newline >_> is it like std::endl or can I just cout a "\n"

              Comment

              • QreepyBORIS
                FFR Player
                • Feb 2003
                • 7454

                #37
                RE: Re: RE: Re: RE: Re: C++ Help

                You can newline two ways.

                Here is and example of each:

                cout << "Cock goes where?\n";
                cout << "Cock goes over there. -->" << endl;

                Okay.

                By the way, you should probably stick the namespace right under your includes. It's just easier than sticking it into every single function in the program.

                And since you missed it: You forgot to return 0! You also forgot to put parentheses around your conditionals. Shame, man. :P

                Signature subject to change.

                THE ZERRRRRG.

                Comment

                • GuidoHunter
                  is against custom titles
                  • Oct 2003
                  • 7371

                  #38
                  Re: RE: Re: RE: Re: C++ Help

                  Code:
                  #include <iostream>
                  using namespace std;
                  
                  void main&#40;&#41;
                  &#123;
                   double x,y;
                  
                   cout << "enter an x and a y";
                   cin >> x;
                   cin >> y;
                   if x==0 && y==0
                      cout << "origin";
                   if x==0 && y!=0
                      cout << "y-axis";
                   if y==0 && x!=0
                      cout << "x-axis";
                   if x > 0 && y > 0
                      cout << "first quadrant";
                   if x < 0 && y > 0
                      cout << "second quadrant";
                   if x<0 && y<0
                      cout << "third quadrant";
                   if x>0 && y<0 
                      cout << "fourth quadrant" ;
                  &#125;
                  Assuming you don't need parentheses around the conditional statements (which I always just put), that code'll work.

                  --Guido


                  Originally posted by Grandiagod
                  Originally posted by Grandiagod
                  She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
                  Sentences I thought I never would have to type.

                  Comment

                  • talisman
                    Resident Penguin
                    FFR Simfile Author
                    • May 2003
                    • 4598

                    #39
                    RE: Re: RE: Re: RE: Re: C++ Help

                    yeah... I was going for the return 0; part... otherwise any half decent compiler will rape you if you try to make it compile that code.

                    Comment

                    • chickendude
                      Away from Computer
                      FFR Simfile Author
                      • Sep 2003
                      • 1901

                      #40
                      Re: RE: Re: RE: Re: C++ Help

                      Code:
                      #include <iostream>
                      main&#40;&#41;
                      &#123;
                       using std&#58;&#58;namespace
                       int x,y;
                      
                       cout << "enter an x and a y \n";
                       cin >> x >> y;
                       if &#40;x==0 && y==0&#41;
                          cout << "origin";
                       if &#40;x==0 && y!=0&#41;
                          cout << "y-axis";
                       if &#40;y==0 && x!=0&#41;
                          cout << "x-axis";
                       if &#40;x > 0 && y > 0&#41;
                          cout << "first quadrant";
                       if &#40;x < 0 && y > 0&#41;
                          cout << "second quadrant";
                       if &#40;x<0 && y<0&#41;
                          cout << "third quadrant";
                       if &#40;x>0 && y<0&#41;
                          cout << "fourth quadrant" ;
                      &#125;
                      ok stupid conditionals parentheses >_<
                      silly me
                      anyway, even though its too late I feel the need to fix it

                      you can do a main without a return I believe.

                      Comment

                      • talisman
                        Resident Penguin
                        FFR Simfile Author
                        • May 2003
                        • 4598

                        #41
                        RE: Re: RE: Re: RE: Re: C++ Help

                        main () isn't even a function... I thought you had to say int main(); which means it has to return an integer. Could be wrong about that.

                        Comment

                        • QreepyBORIS
                          FFR Player
                          • Feb 2003
                          • 7454

                          #42
                          RE: Re: RE: Re: RE: Re: C++ Help

                          You can do void main with some compliers only. But you did not specify a data type for main...what were you thinking? :P

                          Signature subject to change.

                          THE ZERRRRRG.

                          Comment

                          • GuidoHunter
                            is against custom titles
                            • Oct 2003
                            • 7371

                            #43
                            RE: Re: RE: Re: RE: Re: C++ Help

                            I know from experience that the compiler Jurs is using will accept void main() and that you need a function type in front of it.

                            Also, chicken, I'm still not sure of thes, but I would have written the conditional lines like:

                            if ((y==0) && (x==0)

                            I do that just to be safe, but again, I'm not sure exactly which parentheses are actually necessary (although I'm rather certain the outside ones are.

                            --Guido


                            Originally posted by Grandiagod
                            Originally posted by Grandiagod
                            She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
                            Sentences I thought I never would have to type.

                            Comment

                            • JurseyRider734
                              lil j the bad b-word
                              • Aug 2003
                              • 7506

                              #44
                              RE: Re: RE: Re: RE: Re: C++ Help

                              Thank you guys <333 I finished.

                              I got an 83 though because my teacher hates me (from last year) and I finished a day later.
                              Originally posted by Arch0wl
                              I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

                              Originally posted by Afrobean
                              Originally Posted by JurseyRider734
                              the fact that you're resorting to threatening physical violence says a lot anyway.
                              Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.

                              Comment

                              • soccr743
                                FFR Player
                                • Dec 2003
                                • 549

                                #45
                                Re: RE: Re: RE: Re: RE: Re: C++ Help

                                Originally posted by GuidoHunter
                                if ((y==0) && (x==0)

                                I do that just to be safe, but again, I'm not sure exactly which parentheses are actually necessary (although I'm rather certain the outside ones are.
                                Yea, you can use as many as you want, but the easiest way:

                                if (y == 0 && x==0)
                                {
                                }

                                The inside ones are not necessary.

                                -----Soccr743-----

                                Comment

                                Working...