Results 1 to 8 of 8

Thread: Newbie C++ programming,need help!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Newbie C++ programming,need help!

    This usually works the other way around - you show us what you have done and where you get the problems, we help you from there.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Mar 2013
    Posts
    4
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Newbie C++ programming,need help!

    Hi,I am really glad someone has responded to my thread.I really appreciate it. The problem is I have not started in typing out the source code because I still couldn't find a way to solve it. I am still overwhelm by two factor:
    1) The total is being first specified by the user. This can be any number which I find it is 'Infinite' numbers for me to cater to.
    2) Subtraction ranging from 1 to N. The N can be any number which is in the sense 'Infinite' numbers.

    The book is really good in teaching C++ to newbie because of its simple explanation & exercises to apply what readers have learned from the book
    to help improve their programming skill.However, it somehow lack answers for the exercises provided.

    I have thought initially that maybe if I have a deep understanding of the previous example I could solve this exercise. I believe the preview coding which I have shown works because it always eliminates the remainder of the total number given by the user. So in anyway, even if the user randomly subtract the total, the logic is always to elminate the remainder by checking with %3.
    For example, let say the user provides a total of 10.
    11%3 will give a remainder of two. So I will subtract two from it forcing it to be a multiplication of 3.
    Therefore,the total now is 9.
    Next,let say the user subtracts 1.
    The total is 8.
    8%3 will give a remainder of two.I will then subtract two from it forcing it to be a multiplication of 3.
    The total is 6.
    .
    .
    .
    So do you see the pattern now?
    The program is designed that it will meet its target of reaching 3 to win the game.Why so?
    This I believe is also due to the program having the chance to start first in subtracting.
    Hence, whenever it reaches 3, the user will subtract and the computer will win the game by subtracting
    whatever is left.
    Yup,but I still can't figure out the exercise though.
    Do you have any idea of solving it?
    Last edited by bestmaster99; 14th March 2013 at 13:06.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Newbie C++ programming,need help!

    Quote Originally Posted by bestmaster99 View Post
    1) The total is being first specified by the user. This can be any number which I find it is 'Infinite' numbers for me to cater to.
    You store the value in some variable and then operate on it.

    2) Subtraction ranging from 1 to N. The N can be any number which is in the sense 'Infinite' numbers.
    No, it can vary from 1 to the number specified by the user which sits in the variable.

    Do you have any idea of solving it?
    You can use the min-max algorithm. It's a classic when it comes to this particular game.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2013
    Posts
    4
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Newbie C++ programming,need help!

    min-max algorithm?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Newbie C++ programming,need help!

    Yes, min-max algorithm.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2013
    Posts
    4
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Newbie C++ programming,need help!

    I have searched online about min-max algorithm. Haha,I am new to programming.What exactly is the algorithm and how do I write the source code?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Newbie C++ programming,need help!

    Search again then. This algorithm is also called "minimax".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. a newbie..
    By Lady Sophia in forum General Discussion
    Replies: 3
    Last Post: 1st May 2012, 00:15
  2. Replies: 3
    Last Post: 25th September 2011, 18:41
  3. Newbie Says Hi
    By ScottBrady in forum General Discussion
    Replies: 1
    Last Post: 25th July 2011, 02:56
  4. Complete newbie with programming and Qt
    By Jacob in forum Newbie
    Replies: 1
    Last Post: 6th March 2010, 06:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.