Hello, This is for a project my school , it is that given a task that has time (the time it takes to do it ) and gain ( which is money tale wins to make it ) then it will be ordering it , so the task more gain first will do ( anger first) but if they have the same gain is now compared with the time, having more time it will be done first but if times are equal then go first which appeared before the list.
this is my lifted and some tests have already done, example :
aaa February 28
bbb March 20
ccc January 10
*
aaa
ccc
bbb
bbb ccc has more gain but that puts me second
on February 14
b February 30
c May 3
*
b
c
to
here also is not happening.
donut April 50
chocolate January 50
*
donut
chocolate
chocolate January 50
donut April 50
*
donut
chocolate
if well here as they have the same gain but as donut has more hours of first puts chocolate
if you can solve this problem thank you so much , I await your response.
imprimir , is Print my list ( if insertion is for prove is correct )
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
|
void insert3 ( string tarea , int tiempo, int dinero) {
nodo *n_nuevo;
n_nuevo = new nodo (tarea, tiempo, dinero );
n_nuevo ->sig = NULL;
if (head == NULL){ // ve si es vacia
head = tail = n_nuevo;
}else {
if ( n_nuevo -> ganancia > head->ganancia ){ // si la ganacia es mayor
n_nuevo -> sig = head;
head = n_nuevo;
}else if (n_nuevo ->ganancia == head->ganancia){ // si la ganancia es igual
if (n_nuevo->hora > head->hora) { // si la hora es mayor
n_nuevo->sig = head;
head =n_nuevo;
}else if (n_nuevo ->hora == head->hora ){ // si las horas son iguales ira despues que la que esta primera
n_nuevo->sig =head->sig;
head->sig = n_nuevo;
}else {
n_nuevo->sig =head ->sig;
head->sig = n_nuevo;
}
}else {
n_nuevo->sig= head ->sig ;
head->sig = n_nuevo;
}
}
}
void imprimir3() { // esto es que me imprime toda la lista, para ver si los insertar funcionan correctamente
nodo *ptemp ;
ptemp = new nodo ();
ptemp= head ;
if (head ==NULL)
{
cout<< "vacia"<<endl;
}
while (ptemp!=NULL){
cout<<ptemp->name <<endl;
ptemp=ptemp->sig;
}
}
|