Please! i need help on this . it suppose to cut the original linklist of head hp such that the sumM <=m and sumV <=v . this is part of a program that reads an input file of itemsets where each item has cod volume mass . then you key the max volume and max mass for a container . the program has to know how much containers are needed . and stor in each container some items. i did read the file to linkedlist ,and i made an array of pointers each index suppose to point to the items within a store .
/* Create an array of pointer of type item_t of size N where each index points to
set of items in a container .*/
dmat=(item_t **)malloc(*Np*sizeof (item_t *));
if(dmat==NULL){
printf("Memory Allocation Error.\n");
exit(EXIT_FAILURE);
}
temp=hp;
for(i=0;i<*Np;i++){
sumM=0;
sumV=0;
p=temp;
V=temp;
for(;temp!=NULL && (sumM+=temp->mass)<m &&(sumV+=temp->volume)<v;temp=temp->next)
V=V->next;
V=NULL;
dmat[i]=p;
for(p=dmat[i];p!=NULL;p=p->next)
printf(":%s %d %d\t",p->code,p->volume,p->mass);
printf("\n\n");
}
return dmat;
}