why there is no answers ?
May 18, 2012 at 7:53pm UTC
swap for this function
look at this code
I want to work program for the clinic will accept patients on the basis of the patient's condition , queue by linked list .
this is the code without loop and if statement , i must have if statement to check priority , if it is ==1 "Critical condition" and i must make swap , else add them to queue .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
struct personal_rec
{
string name;
int birth;
};
struct patient
{
int id;
int pr;
string status;
personal_rec person;
patient *next;
};
void enqueu ( patient *& , patient *&);
int main()
{
patient * front=NULL , * rear=NULL;
enqueu ( rear , front);
return 0 ;
}
void enqueu ( patient *& front , patient *& rear)
{
patient *n;
n=new patient;
cout<<"enter id" <<endl;
cin>>n->id;
cout<<"enter name" <<endl;
cin >> n->person.name;
cout<<"enter birth" <<endl;
cin >> n->person.birth;
cout<<"enter status" <<endl;
cin >> n->status;
cout<<"enter priority" <<endl;
cin>>n->pr;
n->next=NULL;
if (front==NULL)
{
front=n;
rear=n;}
else
if (n->pr==0)
{
rear->next=n;
rear=n;
}
else
{// here i need code for swapping
}
}
May 18, 2012 at 8:17pm UTC
Topic archived. No new replies allowed.