Thread: STUDENTS - homework

  1. #1
    3rd Week In C++ SRS's Avatar
    Join Date
    Nov 2007
    Posts
    22

    STUDENTS - homework

    I am trying to learn C++ and I am tired of aimlessly throwing code on screen and trying to make something of it. (example: my 4 function - .text reading - .html creating "Hello World" program)...

    I would like you all to post your favorite homework assignment for me... as if you were to assign it to me, only giving me what your instructor give you. You do not have to be willing to help with it, and don't spoil the fun by supplying the code . That way myself, and other people new to C++ who are not in school can look here for a new idea to try to write.

    Thank you all
    Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    There are various projects you can look into doing.

    Depending on your skills will depend on what sort of program you can write. Somthing pointer and advanced OOP heavy may be out of your or other peoples depth at the moment. The best way to learn is from others. Look around the board with a search and see what you can come up with, there have been many program problems posted on the board.
    Double Helix STL

  3. #3
    3rd Week In C++ SRS's Avatar
    Join Date
    Nov 2007
    Posts
    22
    I'm not looking to inherit someone elses error. I am looking for project ideas. The first step of writing a program is the need for one. I have no needs. Also the reason I asked for multiple posts, and not just one... so readers can be selective to their level... besides even an experienced coder might get a fun idea off of some of the homework projects.
    Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Wtrie a porgarm that tkaes txet as iunpt and suhflefs the lrteets on the idnise of ecah word aorund but levaes the first and last lteter (and any pcnuiaottun) in the smae spot, then ouputts the new text for the uesr to use. Most fnulet Eisnlgh sekaeprs wlil siltl be albe to raed the text.

  5. #5
    Registered Abuser
    Join Date
    Sep 2007
    Location
    USA/NJ/TRENTON
    Posts
    127
    A deck of cards contains 52 cards (4 suits, each w/13 different values).

    Write a menu-driven program that can:

    1. Shuffle the deck of cards.
    2. Deal out any number of equal amounts of cards to up to 52 different players. (If you have 6 players, the maximum number of cards that can be dealt to each player is 8)

    6 * 8 = 48 total cards dealt.

    52 - 48 = 4 cards not dealt.

  6. #6
    Registered User
    Join Date
    May 2007
    Posts
    77
    Quote Originally Posted by Daved View Post
    Wtrie a porgarm that tkaes txet as iunpt and suhflefs the lrteets on the idnise of ecah word aorund but levaes the first and last lteter (and any pcnuiaottun) in the smae spot, then ouputts the new text for the uesr to use. Most fnulet Eisnlgh sekaeprs wlil siltl be albe to raed the text.
    Man, that's complicated, and could be huge...
    Wouldn't you have to use an array for that? At least, that would be the easiest, wouldn't it?
    Last edited by Molokai; 11-06-2007 at 02:32 PM.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Nah... it's not that bad. I did it in about 14 lines of code, not counting #includes. The trick is coming up with the algorithm, which is an extremely important skill in programming.
    Last edited by Daved; 11-06-2007 at 02:34 PM.

  8. #8
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Molokai View Post
    Man, that's complicated, and could be huge...
    Taking this directly from my back-side, but... I estimate it could be solved in under 10 lines of code, if done cleverly.

    EDIT: Daved says 24, so let's just arbitrarily whack 20% off that -- do it in 19 lines

  9. #9
    Registered User
    Join Date
    May 2007
    Posts
    77
    So, there is an algorithm for that, or you have to make your own?
    I'm assuming you have to make your own, so where is a good place to learn about making an algorithm?

  10. #10
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I counted blank lines and stuff... I got it down to 14 lines (3 of which are closing braces). The code assumes that the input comes from cin and ends with a newline (or some other not alpha character), so a proper version might need more.

    >> So, there is an algorithm for that, or you have to make your own?
    You have to come up with your own. What I mean by algorithm is just the list of steps to solve the problem, not an algorithm function from <algorithm>.

  11. #11
    Registered User
    Join Date
    May 2007
    Posts
    77
    Ah, I see.

  12. #12
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    How 'bout this one. It was a project my first semester of c/c++. Luckily I knew a lot more than what that class encompassed, so it wasn't hard, but it shouldn't be out of your reach if you know how to work with arrays and file streams. Being good with math will definitely help too
    Last edited by scwizzo; 11-06-2007 at 03:13 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program using structs to calculate grades
    By TampaTrinDM88 in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 12:33 PM
  2. realloc segfaults.
    By noobcpp in forum C Programming
    Replies: 24
    Last Post: 11-26-2008, 01:16 AM
  3. new problem with class
    By jrb47 in forum C++ Programming
    Replies: 0
    Last Post: 12-01-2006, 08:39 AM
  4. IEEE Society for Students
    By Ben_Robotics in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-26-2003, 08:53 AM
  5. CalPoly SLO && Gonzaga Students
    By alpha in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 04-17-2003, 03:53 PM