Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SORTED *selectsortList(SORTED *main,SORTED *cpt,SORTED *ppv, SORTED *pnew, SORTED *pnhd, int ct) {
int p , x;
SORTED *ppt;
/*( if at beginning or end of list start over */
if (cpt == NULL) {
cpt = main;
}
/*memprint(cpt,"Assigned mem to cpt");*/
/* check for values */
for (ppt=main ; ppt != NULL ; ppt = ppt->pnxt) {
printf("comparing %d ppt to %d cpt\n",ppt->data, cpt->data);
if (cpt->data < ppt->data && ppt->data > 0) {
printf("At count: %d\n", ct);
ct++;
ct = ct <= printList(main,0) ? ct : 0;
return selectsortList(main,cpt->pnxt,ppv,pnew,pnhd,ct);
}
}
x = printList(main,0); p = printList(pnhd,0);
if (x == p) {
printList(pnhd,1);
return pnhd;
}
if (ppv == NULL) {
pnew = createnewElement();
pnew->data = cpt->data;
setNull(main,cpt->data);
cpt = NULL;
ppv = pnew;
pnhd = pnew;
return selectsortList(main,cpt,ppv,pnew,pnhd,ct);
} else {
pnew = createnewElement();
ppv->pnxt = pnew;
pnew->data = cpt->data;
setNull(main,cpt->data);
cpt = NULL;
return selectsortList(main,cpt,ppv->pnxt,ppv,pnhd,ct);
}
return NULL;
}