Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS301 Assignment no 1
#11
Code:
#ifndef LINKEDLIST_H #define LINKEDLIST_H #include using name space std; template span>class T> class LList { Private: class ListNode { friend class LList; T value; ListNode *nest; ListNode(T value1, ListNode *next1=NULL) { value=value1; next=next; } }; ListNode *head; public: LList() { head=NULL; ) ~LList(); void appendNode(T); void insertNode(T); void deleteNode(); voide displayList(); void MoveNext(); void ShowCurrent(); }; template voidLList::appendNode(T val) { if(head=NULL) head=new ListNode(val); else { ListNode *nodePtr; while (nodePtr->next !=NULL) nodePtr->next=new ListNode(val); } } template voidLList::displayList() { ListNode *nodePtr; nodePtr =head; while (nodePtr) { cout nodePtr->value endl; nodePtr =nodePtr->next; } } template voidLList::ShowCurrent() { ListNode *nodePtr; nodePtr=head; countnodePtr->value endl; } template voidLList::MoveNext() { ListNode *nodePtr; nodePtr=head; while (nodePtr) { nodePtr = nodePtr->next; } } template voidLList::insertNode(T val) { ListNode *nodePtr, *previousNodePtr; if(head==NULL || head->value>=val) { head=new ListNode(val, head); } else { previousNodePtr=head; nodePtr = head->next; while (nodePtr !=Null&&nodePtr->value { previousNodePtr=NodePtr; nodePtr = nodePtr->next; previousNodePtr->nest=new ListNode(val, nodePtr); template voidLList::deleteNode() { ListNode *nodePtr, *previousNodePtr; if(!head) return nodePtr=head; head=head->next; deletenodePtr; } template LList::~LList () { ListNode *nodePtr, *nextNodePtr; nodePtr=head; while (nodePtr !=NULL) { nextNodePte=nodePtr->nest; delete nodePtr; nodePtr=nextNodePtr; } } #endif Source of Mail Program #include #include #include #include "LList.h" int main() { int TotalPersons=0,NumberofPasses, LoopCounter=0,a=0,b=0; string NameToAppend count"how many people will play parates of Carribeans : course of black pearl game? "; cin>>TotalPersons; count"how many passes will be displayed? "; cin>>NumberofPasses; LListlist; while(LoopCounter <=TotalPersons) { count"enter players name: "; cin>>NameToAppend list.appendNode(nameToAppend); LoopCounter +=1; } while(a<=TotalPersons-1) { for(int c=0;c<=NumberodPasses;c++) { list.MoveNext(); } count"removing :"; list.deleteNode(); list.ShowCurrent(); a+=1; } count"\nthe survivor is"; list.displayList(); getch();

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need ACC501 - Business Finance Assignment No 2 Solution. Umar Abbas 2 4,251 02-07-2014, 08:23 PM
Last Post: Umar Abbas
  sta301 assignment 4 27 jun bc110200090 6 3,580 01-26-2013, 02:05 AM
Last Post: Vuhelper
  cs506 2nd assignment millee 0 2,661 12-04-2012, 11:30 PM
Last Post: millee
  cs506 2nd Assignment Neelam Ahmad 5 3,130 12-04-2012, 11:24 PM
Last Post: Vuhelper
  CS 504 Assignment 2 need help ommmi 24 11,422 11-27-2012, 04:59 AM
Last Post: Xpert
  Mcs cs402 1st assignment chahat4all 2 3,767 11-01-2012, 11:11 PM
Last Post: chahat4all
  eng201 assignment 4 due date 4/7/2012 bc110200090 6 2,615 07-03-2012, 03:51 PM
Last Post: bc110200090
  need CS304 4th assignment shazma 0 2,056 06-26-2012, 12:48 PM
Last Post: shazma
  sta301 assignment 4 solution vudecent 0 2,399 06-25-2012, 01:51 AM
Last Post: vudecent
  Required Soluction for 3rd Assignment of CS101 bc120200426 1 2,138 06-14-2012, 04:13 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)