PDA

View Full Version : CS301 Data Structures assignment no 1 spring 25 October 2011



Vuhelper
10-25-2011, 10:35 PM
It is required to make a list of students registered in Data Structures course. To achieve this functionality, develop a C++ program and use linked list to store student ids and names.
Each node in the linked list will contain three items: student id, student name, pointer to next node.
When the program starts, it should display the following menu:
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Sample Run:
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 1 (Suppose user entered 1)
(Now the details of Student will be entered)
Student ID: bc080400001 (Suppose user entered bc080400001)
Student Name: Ahmad (Suppose user entered Ahmad)
(If user enters an ID that is already in the list, a message should be displayed “Already in the list.”)

(Main menu will be displayed again)
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 2 (Suppose user entered 2)
Student ID: bc080400001 (Suppose user entered bc080400001)
(Now the details of Student will be displayed)
Student ID: bc080400001
Student Name: Ahmad
(If user enters an ID that is not in the list, a message should be displayed “Record not found.”)

(Main menu will be displayed again)
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 4 (Suppose user entered 4)
(Now it will ask to enter ID to be deleted)
Student ID: bc080400001 (Suppose user entered bc080400001)
(Student record with this ID will be deleted.)

(Main menu will be displayed again)
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 5 (Suppose user entered 5)
(Now it will print all students’ information. Suppose there were three students in the list, so it will print: )
Student ID Student Name
------------- ---------------------
bc080400001 Ahmad
bc080200010 Ali
mc070400002 Hassan

Virtual123
10-27-2011, 05:38 PM
solution file do na
yeh to lms per b mlti hay

rabeel
10-27-2011, 06:18 PM
woh tu mil hi jay gi ek na ek din. lms say bhi mil jati hai

ladak
10-29-2011, 02:09 AM
vuhelp.net ka naam aap change kar kay vuhelpless.net rakh lo.

makyle
11-01-2011, 04:57 PM
Dear all the last date of this assignment is 1st november, gays please arrange for soluation. we are living far apart from net in mountain.

makyle
11-01-2011, 05:06 PM
hahahahahaha ahahha haha

KKANWAL ALMAS
11-01-2011, 05:32 PM
solution ??????????????????????

Hina Khan
11-02-2011, 12:31 AM
solution kb aaye ga zalimon????????? jb pani sir se guzar jae ga.

Hina Khan
11-02-2011, 12:42 AM
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaa!!!!!!
"Aaj nahi btao gay to kl bhugto gay"
Assignment bhaij or kr
"KHAMOSHI KA BYCOT"

rabeel
11-02-2011, 01:38 AM
HAHAHha very funny

khola
11-02-2011, 02:06 AM
:'( :'( :'(

makyle
11-02-2011, 04:27 AM
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
class expression
{
private:
char infix[100];
char stack[200];
int first;
int r;
char postfix[100];
public:
void convert();
int input_p(char);
int stack_p(char);
int rank(char);
};
int expression::input_p(char c)
{
if(c=='+' || c=='-')
return 1;
else if(c=='*' || c=='/')
return 3;
else if(c=='^')
return 6;
else if(isalpha(c)!=0)
return 7;
else if(c=='(')
return 9;
else if(c==')')
return 0;
else
{
cout<<"Invalid expression ::input error\n";
exit(0);
}
}
int expression::stack_p(char c)
{
if(c=='+' || c=='-')
return 2;
else if(c=='*' || c=='/')
return 4;
else if(c=='^')
return 5;
else if(isalpha(c)!=0)
return 8;
else if(c=='(')
return 0;
else
{
cout<<"Invalid expression ::stack error\n";
exit(0);
}
}
int expression::rank(char c)
{
if(c=='+' || c=='-')
return -1;
else if(c=='*' || c=='/')
return -1;
else if(c=='^')
return -1;
else if(isalpha(c)!=0)
return 1;
else
{
cout<<"Invalid expression ::in rank\n";
exit(0);
}
}
void expression::convert()
{
cout<<"\n************************************************ *\n"
<<"This program converts the given infix expression\n"
<<"in to postfix form"
<<"\n************************************************ *\n";
cout<<"Enter an infix expression ::\n";
cin>>infix;
int l=strlen(infix);
infix[l]=')';
infix[l+1]=";
//Convertion starts
first=1;
stack[first]='(';
r=0;
int x=-1;
int i=0;
char next=infix[i];
while(next!=")
{
//Pop all the elements to outputin stack which have higher precedence
while( input_p(next) < stack_p(stack[first]) )
{
if(first<1)
{
cout<<"invalid expression ::stack error\n";
exit(0);
}
postfix[++x]=stack[first];
first-;
r=r+rank(postfix[x]);

if(r<1)
{
cout<<"Invalid expression ::r<1\n";
exit(0);
}
}
if(input_p( next ) != stack_p( stack[first]))
stack[++first]=next;
else
first-;
i++;
next=infix[i];
}
postfix[++x]=";
if(r!=1 || first!=0)
{
cout<<"Invalid expression ::error in rank or stack\n";
exit(0);
}
cout<<"\n\nThe corresponding postfix expression is ::\n";
cout<<postfix<<endl;
}
int main()
{
expression obj;
obj.convert();
return 0;

rabeel
11-02-2011, 04:32 AM
is it compiling and not giving any error?

makyle
11-02-2011, 07:38 PM
It is required to make a list of students registered in Data Structures course. To achieve this functionality, develop a C++ program and use linked list to store student ids and names.
Each node in the linked list will contain three items: student id, student name, pointer to next node.
When the program starts, it should display the following menu:
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Sample Run:
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 1 (Suppose user entered 1)
(Now the details of Student will be entered)
Student ID: bc080400001 (Suppose user entered bc080400001)
Student Name: Ahmad (Suppose user entered Ahmad)
(If user enters an ID that is already in the list, a message should be displayed “Already in the list.”)

(Main menu will be displayed again)
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 2 (Suppose user entered 2)
Student ID: bc080400001 (Suppose user entered bc080400001)
(Now the details of Student will be displayed)
Student ID: bc080400001
Student Name: Ahmad
(If user enters an ID that is not in the list, a message should be displayed “Record not found.”)

(Main menu will be displayed again)
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 4 (Suppose user entered 4)
(Now it will ask to enter ID to be deleted)
Student ID: bc080400001 (Suppose user entered bc080400001)
(Student record with this ID will be deleted.)

(Main menu will be displayed again)
1- Enter student information
2- Search student by ID
3- Search student by Name
4- Delete student information
5- Print all students
6- Quit
Enter your choice: 5 (Suppose user entered 5)
(Now it will print all students’ information. Suppose there were three students in the list, so it will print: )
Student ID Student Name
------------- ---------------------
bc080400001 Ahmad
bc080200010 Ali
mc070400002 Hassan

Xpert
11-02-2011, 08:04 PM
yah dubara post ker di

Vuhelper
11-03-2011, 04:56 PM
#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();

sam112mughal
11-10-2011, 02:10 AM
AOA
bhai ye kia solution ha!!
if u want to help someone then help him/her complete!
thanks anyway.....

rabeel
11-10-2011, 03:41 AM
janab thake hi tu hai. ab baki compile tu khud kar len na.