Computer Science, asked by dhanamvijay2002, 10 months ago

Please help me FRIENDS...

Write a C++ program.

In this exercise you will write a program that keeps track of who is in a certain classroom.  At the start, the classroom is empty.Then for some time, students keep arriving and departing until the door finally closes.These events are given to the program as input consisting of lines of the following form

a x : This says student with roll number x arrived into the class room.

d x : This says student with roll number x departed from the class room.

c : This says the door closed.
After this you should print the roll numbers of the students who are in the class room (in increasing order), one per line and the program should stop.Arrivals and departures can happen in any order; and you can assume that a student departs only if she was present and arrives only if she was not present earlier.  Assume further that the roll numbers are in the range 0 through 99.  You should use a bool array present of size 100, and use the invariant: present[i] should be true if and only if student with roll number i is present in the class room.


Attachments:

Answers

Answered by rohanpawar10906
0

Answer:

yaar send the clear photo of this question

Answered by Anonymous
0

Answer:

#include<stdio.h>

#include<simplecpp>

int main()

{

int  a[100],  b[100];

int i=1, j =1;

while(true)

{

char command;

cin >> command;

if(command == 'a')

{

   cin >> a[i];

   for(int k = 1; k<=i; k++)

   {

   for(int l = k+1 ; l<=i; l++)

   {

       if(a[k]== a[l])

       {

           a[l] = 0;

           break;

       }

       else if(a[k]!=a[l])

       {

       continue;

       }

   }

   }

   i = i+1;

   }

else if(command == 'd')

{

   cin>>b[j];

   for(int l = 1; l<=i; i++)

   {

   if(b[j]==a[l])

       {

           a[l]= 0;

           break;

       }

       else if(b[j]!=a[l])

       {

           continue;

       }

   }

   j = j+1;

}

else if (command == 'c')break;

else cout<<"Illegal Command" << endl;

}

for(int p =1; p<=i; p++)

{

int temp;

for(int q = p+1; q<=i; q++)

if(a[p]>a[q])

{

 if(a[p]<100 && a[p] >0)

 {

temp = a[p];

a[p] = a[q];

a[q] = temp;

}

}

}

for(int p = 1; p<= i; p++)

{

for(int q= 1; q<=j; q++)

{

if (a[p]!= b[q])

{

if(a[p]<100 && a[p]>0)

{

   cout<< a[p] << endl;

  break;

}

}

}

}

}

Explanation:

Similar questions