Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created April 3, 2011 16:03
Show Gist options
  • Save spellancer/900521 to your computer and use it in GitHub Desktop.
Save spellancer/900521 to your computer and use it in GitHub Desktop.
сортировка списка
for (i=1;i<k;i++)
{tmp=new spisok;
for (j=0;j<strlen(st[i]);j++)
{
tmp->num[j]=st[i][j];
}
if ((tmp->num[i])>=(last->num[i]))
{
last->next=tmp;
tmp->prev=last;
tmp->next=NULL;
last=tmp;
}
else
if ((tmp->num[i])<=(first->num[i]))
{
first->prev=tmp;
tmp->next=first;
first=tmp;
first->prev=NULL;
}
else
{
qq=last;
while ((tmp->num[i]) < (qq->num[i]) )
{
qq=qq->prev;
}
(qq->next)->prev=tmp;
tmp->next=qq->next;
tmp->prev=qq;
qq->next=tmp;
}
tmp->num[j]='\0';
/*last->next=tmp;
tmp->prev=last;
tmp->next=NULL;
last=tmp;
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment