
-----------------------------------
shanebond
Thu Nov 18, 2010 3:15 am

sorting technique c/c++ code
-----------------------------------
Hello everyone i'm new to this kind of things plz help me to solve this , if anyone can post the c/c++ code also i shall be thankfull to you :)

An eccentric doctor visits his patients in order of decreasing age. Patients entering the waiting list specify not only their names but also their ages. Each time the doctor wants to visit a patient, the oldest is selected and removed from the list (so children may have to wait a very long time). Write a program, based on elementary sorting techniques to sort this list on first on Age and then on Patient ID, which this doctor can use.

          Before

PatientID	Name	Age
P102	Arif Taj Mairza	50
P203	Sadar Khan	65
P546	Afsheen Bano	34
P605	Kai Whong	45
P340	Hanah Duong	23
P391	Usman Habib	65
P200	Alina Shah	34

            After
PatientID	   Name    	Age

P203	Sadar Khan	65
P391	Usman Habib	65
P102	Arif Taj Mairza	50
P605	Kai Whong	45
P200	Alina Shah	34
P546	Afsheen Bano	34
P340	Hanah Duong	23

                                                

Solve this problem by applying four different elementary sorting techniques that are

a)	Selection sort
b)	Bubble sort
c)	Insertion sort
d)	Shell sort

-----------------------------------
rdrake
Thu Nov 18, 2010 4:11 am

Re: sorting technique c/c++ code
-----------------------------------
I kept deleting your threads, but they just kept popping up.  Since I deleted yet another one of your duplicate threads with a response this time, let me quote it here.

A: Never make multiple threads in different places. This is actually where it belongs. 

B: We don't do your work for you. Steer you in the right direction, perhaps, but nothing more. I realize you are new here, so I am merely letting you know how things work around here before other people get offended.As was said above, we will not do your work.  We can, of course, point you [url=http://en.wikipedia.org/wiki/Selection_sort]in [url=http://en.wikipedia.org/wiki/Bubble_sort]the [url=http://en.wikipedia.org/wiki/Insertion_sort]right [url=http://en.wikipedia.org/wiki/Shell_sort]direction.

An enterprising copy paster should be able to find C++ implementations of all the required sorting algorithms on Google.  Of course, this does not appear to be the case.  You appear to be doing a very poor job of cheating on your assignment.

Attempt to solve it yourself and post back if you get stuck.

-----------------------------------
shanebond
Thu Nov 18, 2010 6:51 am

RE:sorting technique c/c++ code
-----------------------------------
i have done this so far , now plz guide me how to sort this with respect to patient id and age 

#include 
using namespace std;

typedef struct
{
char name[100];
int patientno;
int age;
} Input;

int main (int argc, char *argv[],int pno)
{
int i;
int NUMBER_OF_PATIENTS;

coutNUMBER_OF_PATIENTS;

Input input[NUMBER_OF_PATIENTS];
int patientno;

for (i=0; i < NUMBER_OF_PATIENTS; ++i)
{
coutinput[i].patientno;

coutinput[i].name;

coutinput[i].age;
}
for (i=0; i