Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,672 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,178 people online right now. Registration is fast and FREE... Join Now!




Linked list and classes

 
Reply to this topicStart new topic

Linked list and classes

vintage
post 3 Sep, 2007 - 05:29 AM
Post #1


New D.I.C Head

*
Joined: 3 Sep, 2007
Posts: 3


My Contributions


I have problem with one of the programming using C++ that involve linked list and classes.

pm me pls. tongue.gif
User is offlineProfile CardPM

Go to the top of the page

Bench
post 3 Sep, 2007 - 05:47 AM
Post #2


D.I.C Addict

Group Icon
Joined: 20 Aug, 2007
Posts: 602



Thanked 10 times

Dream Kudos: 150

Expert In: C/C++

My Contributions


What problem have you got?
Post your code so far, & errors you've encountered (if any), and try to describe what exactly you need help with, then someone will be able to help you out. (In the forum, not over PM)
User is offlineProfile CardPM

Go to the top of the page

vintage
post 3 Sep, 2007 - 05:54 AM
Post #3


New D.I.C Head

*
Joined: 3 Sep, 2007
Posts: 3


My Contributions


OOps..sorry..coz in the forum i joined, usually pple will pm instead. tongue.gif guess its a different culture here.

anyway, im new to this C++ programming thing. i have a problem to solve which i don't understand. and my classmate aren't willing to help me either, guess they are sexist. crazy.gif

anyway, the problem goes like this

A group of soldiers are queued arbitrarily in several rows.
Each of them is given a unique natural number as his ID.
Now they are supposed to be rearranged to form nice queues.

The allowed operations on the queues are

drmove n r1 r2
Move the n-th soldier in row r1 to the end of row r2.

srmove n r m
Move the n-th soldier in row r so that after the move
the soldier is in the m-th position in the same row.

join r1 r2
Join row r1 to the back of row r2.

dispatch n r
Delete the n-th soldier from row r


i honestly dun understand. can someone advise.. really feel like giving up on this. blink.gif

this is my first problem and i hope someone can enlighten me. my 1st time taking C++ and i hope that after getting help on this i can actually move on to my future task much easier.
User is offlineProfile CardPM

Go to the top of the page

Bench
post 3 Sep, 2007 - 07:41 AM
Post #4


D.I.C Addict

Group Icon
Joined: 20 Aug, 2007
Posts: 602



Thanked 10 times

Dream Kudos: 150

Expert In: C/C++

My Contributions


Start out by representing your soldiers just with an id number - you can make your problem into one of building a linked list that stores int's.

If you can create one working linked list which just stores int values, and outputs them again then that would be a start. You can worry about moving list nodes around later on.

(Hint - a simple list node need not be any more complicated than this)
CODE
struct node
{
    int data;
    node* next;
};



Somehow I have trouble believing this can be your first ever programming problem if you've really never programmed before! Dynamic data structures such as linked lists are usually subjects covered in an intermediate/advanced programming course.

Is it the case that you've enrolled on a higher course and missed out a whole lot of other material from the beginner class?
Or have you missed earlier material in this class, and this is the first one that you've tried?

in either case, you ought to make sure you're comfortable with the foundation material and tackle some simpler problems first, before even thinking about this.

Out of curiousity, how much of the following list of topics have you covered..?

input/output
variables & data types
struct's / classes
functions, parameters and return values
header files & C/C++ library features
for, while, do-while loops
recursion
if/else statements
switch-case statements
strings
vectors or arrays
pointers
dynamic memory allocation

Most of these are topics typically covered in a beginner class - Unless you've genuinely studied, and solved problems with most of the things I've listed there, I have a feeling you're a little out of your depth with linked lists.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 06:13AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month