free geoip

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS301 Data Structures assignment no 1 spring 25 October 2011
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#11
:'( :'( :'(
Reply
#12
#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©!=0)
return 7;
else if(c=='(')
return 9;
else if(c==')')
return 0;
else
{
cout<<"Invalid expression ::input error\n";
exit(0);
}
}
int expression:Confusedtack_p(char c)
{
if(c=='+' || c=='-')
return 2;
else if(c=='*' || c=='/')
return 4;
else if(c=='^')
return 5;
else if(isalpha©!=0)
return 8;
else if(c=='(')
return 0;
else
{
cout<<"Invalid expression :Confusedtack 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©!=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 :Confusedtack 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;
Reply
#13
is it compiling and not giving any error?
[SIZE="3"]03009520262[/SIZE]
Rabeel Website
Reply
#14
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.
[FONT=&quot]Each node in the linked list will contain three items: student id, student name, pointer to next node.[/FONT]

[FONT=&quot]When the program starts, it should display the following menu:[/FONT]
[FONT=&quot]1- [/FONT][FONT=&quot]Enter student information[/FONT]
[FONT=&quot]2- [/FONT][FONT=&quot]Search student by ID[/FONT]
[FONT=&quot]3- [/FONT][FONT=&quot]Search student by Name[/FONT]
[FONT=&quot]4- [/FONT][FONT=&quot]Delete student information[/FONT]
[FONT=&quot]5- [/FONT][FONT=&quot]Print all students[/FONT]
[FONT=&quot]6- [/FONT][FONT=&quot]Quit[/FONT]
[FONT=&quot]Sample Run:[/FONT]
[FONT=&quot]1- [/FONT][FONT=&quot]Enter student information[/FONT]
[FONT=&quot]2- [/FONT][FONT=&quot]Search student by ID[/FONT]
[FONT=&quot]3- [/FONT][FONT=&quot]Search student by Name[/FONT]
[FONT=&quot]4- [/FONT][FONT=&quot]Delete student information[/FONT]
[FONT=&quot]5- [/FONT][FONT=&quot]Print all students[/FONT]
[FONT=&quot]6- [/FONT][FONT=&quot]Quit[/FONT]
[FONT=&quot]Enter your choice: 1 (Suppose user entered 1)[/FONT]
[FONT=&quot](Now the details of Student will be entered)[/FONT]
[FONT=&quot]Student ID: bc080400001 (Suppose user entered bc080400001)[/FONT]
[FONT=&quot]Student Name: Ahmad (Suppose user entered Ahmad)[/FONT]
[FONT=&quot](If user enters an ID that is already in the list, a message should be displayed “Already in the list.”)[/FONT]

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

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

[FONT=&quot](Main menu will be displayed again)[/FONT]
[FONT=&quot]1- [/FONT][FONT=&quot]Enter student information[/FONT]
[FONT=&quot]2- [/FONT][FONT=&quot]Search student by ID[/FONT]
[FONT=&quot]3- [/FONT][FONT=&quot]Search student by Name[/FONT]
[FONT=&quot]4- [/FONT][FONT=&quot]Delete student information[/FONT]
[FONT=&quot]5- [/FONT][FONT=&quot]Print all students[/FONT]
[FONT=&quot]6- [/FONT][FONT=&quot]Quit[/FONT]
[FONT=&quot]Enter your choice: 5 (Suppose user entered 5)[/FONT]
[FONT=&quot](Now it will print all students’ information. Suppose there were three students in the list, so it will print: )[/FONT]
[FONT=&quot]Student ID Student Name[/FONT]
[FONT=&quot]------------- ---------------------[/FONT]
[FONT=&quot]bc080400001 Ahmad[/FONT]
[FONT=&quot]bc080200010 Ali[/FONT]
[FONT=&quot]mc070400002 Hassan[/FONT]
Reply
#15
yah dubara post ker di
Reply
#16
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
#17
AOA
bhai ye kia solution ha!!
if u want to help someone then help him/her complete!
thanks anyway.....
Reply
#18
janab thake hi tu hai. ab baki compile tu khud kar len na.
[SIZE="3"]03009520262[/SIZE]
Rabeel Website
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CS301 Assignment # 4 Due Date: 02-Feb-2016 Vuhelper 0 2,343 02-03-2016, 05:38 PM
Last Post: Vuhelper
  CS703 – Advanced Operating Systems Assignment No.3 solution January 2016 Vuhelper 0 5,933 01-23-2016, 09:58 PM
Last Post: Vuhelper
  CS601 Data Communication Assignment No. 03 Solution 23rd January 2016 Vuhelper 1 1,955 01-23-2016, 06:09 PM
Last Post: Vuhelper
  CS403 Assignment No. 03 Solution 23rd January 2016 Vuhelper 2 1,195 01-23-2016, 03:18 PM
Last Post: Vuhelper
  CS506 Web Design and Development Assignment no 3 Solution 3rd January 2016 Vuhelper 0 2,268 01-23-2016, 03:16 PM
Last Post: Vuhelper
  CS724 Software Process Improvement Assignment No 01 Solution 20th January 2016 Vuhelper 0 1,993 01-20-2016, 06:26 PM
Last Post: Vuhelper
  CS711 Software Design Assignment No 01 Solution Due Date Feb 12, 2016 Vuhelper 0 1,688 01-20-2016, 06:24 PM
Last Post: Vuhelper
  CS709 Formal Methods for Software Engineering Assignment No 01 Solution January 2016 Vuhelper 0 1,829 01-20-2016, 06:22 PM
Last Post: Vuhelper
  cs703 assignment no 3 Solution 20th January 2016 Vuhelper 0 1,725 01-20-2016, 06:20 PM
Last Post: Vuhelper
  CS704 Assignment No. 01 Solution January 2016 Vuhelper 0 4,821 01-20-2016, 06:19 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support