Thread: c++ program

  1. #16
    Registered User
    Join Date
    Nov 2002
    Posts
    126
    Code:
    i think die is more easy to me than solve this program
    I take it English is not your first language...

    If you want to program in C++, you really need to understand what a class is. Understanding that is more important than understanding how to implement this one program. Because you are trying to implement your own linked list, I assume that you are trying to code this in C and not C++. In that case, you need to make a structure for each student, maybe like this:

    Code:
    typedef struct {
    
    char 	name[64];
    int 	marks[5]; //I just have to assume there's 5...
    float 	average;
    char 	grade;
    
    } STUDENT;
    Now, since you want it to make a linked list, you should have another structure that looks like this:
    Code:
    typedef struct {
    
    STUDENT 	student;
    STUDENT* 	next;
    
    } STUDENT_NODE;
    Each STUDENT_NODE contains a student and a pointer to the next student in the list. You also need to make functions that will add and delete things in your list. It might also be a good idea to make a function that finds a specific student out of a list and returns its node pointer. I don't want to go over the implementation of those. I hope that helps a little bit

  2. #17
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Originally posted by a_a
    hi i study but i want to know the solution so i can understand
    the linked list , i search for web site to learn it but no good web site
    so what i do !
    here's a linked list:
    Code:
    /*
    	linked.cpp => Linked Lists
    
    	These are notes for myself that will help with linked lists. It is a working
    	Linked list that, when run, will print out every List Item in the form of
       it's number in the line.
    
    	Major_Small
    */
    
    #include <iostream.h>   // don't use this -> use the next two lines of code instead
    
    //#include <iostream>
    //using namespace std;
    
    int main()
    {
    	int i;	//loop control variable
    	struct list;	//structure declaration - needed for typedef
    	typedef list *ptrList;	//typedef - makes life easier
    
    	struct list 	//structure
    	{
    		int variable;	//this list item's data
    		ptrList link;	//pointer to next list item (note typedef use here)
    	};
    
    	ptrList	curr;	//current list item in focus
    	ptrList	next;	//next list item in line
    	ptrList	head; //first list item in line
    
    	head=new list;	//create first list item
    	curr=head;		//point 'curr' to first list item
    
    	curr->link=NULL;	//set first list item's pointer to NULL so it doesn't look
    							//for something that doesn't exist
    	for(i=0;i<25;i++)	//runs 25 times
    	{
    		next=new list;	//creates a new list item
    		curr->link=next;	//current list item set to point to next list item
    		curr->variable=i+1;	//current variable gets something
    		curr=next;	//focus changed to next list item
    	}
    
    	/*	AT THIS POINT, THE LINKED LIST IS COMPLETE - WHAT IS BELOW IS TO PRINT
    	OUT THE LINKED LIST.  THE CONSTANTS IN THE LIST ARE THAT 'HEAD' IS THE FIRST
    	LIST ITEM, AND 'NEXT' IS THE LAST LIST ITEM.  THE LAST LIST ITEM SHOULD HAVE
    	ITS POINTER POINTING TO NULL */
    
    	curr->link=NULL;	//last list item's pointer set to NULL for same reason
    	curr=head;	//current points back to first - NOT NECESSARY - for printing
    
    	for(i=0;i<25;i++)	//runs 25 times to print
    	{
    		cout<<curr->variable<<endl;	//print what is in curr (ini to head above)
    		curr=curr->link;	//move focus along list
    	}
    
       return 0;
    }
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #18
    Registered User
    Join Date
    Dec 2002
    Posts
    221
    Originally posted by a_a
    we didnt study class
    not in our subject
    does anyone else find this kind of weird considering that C++ IS AN OBJECT ORIENTED language?

    its like taking calc and not learning to derive functions

  4. #19
    Registered User
    Join Date
    May 2003
    Posts
    11
    hi
    thank for all people who try to help me
    and im very sad because some people here talk to me like stubid !
    if some body tell you that he need help help him or not , not try laugh at him
    yes english not my first languge

  5. #20
    Registered User
    Join Date
    May 2003
    Posts
    11
    no body answer me !
    why

  6. #21
    Registered User
    Join Date
    May 2003
    Posts
    11
    first of all
    this not home work !
    second
    i go to my doctor and he solve it to me
    i dont need you in solve my home works dont woory
    all what i want yesturday to understand it
    but all of you think that i need all solution
    so
    in the end
    i feel that your website is not helpful for cs students

    and thank for pepole who try to help me

    bye

  7. #22
    Registered User
    Join Date
    Mar 2003
    Posts
    73
    I read all the posts, and I found them to help ME understand linked lists better and I didn't even ask the question! A lot of people did practically post what you had to do. I'm sorry you feel that way....

  8. #23
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    you're going to have to do some work to get anywhere... you can't learn the harder algorithms well by copying and pasting...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM