Односвязный список с++
вот структура
Код:
struct TNode {
int value;
TNode* pnext;
};
int value;
TNode* pnext;
};
Код:
void add2list2(TNode **pphead, int val, int A, int B)
{
TNode **pp = pphead, *pnew, *var1, *var2;
while(*pp)
{
if(val < (*pp)->value)
break;
else
pp = &((*pp)->pnext);
}
pnew = new TNode;
pnew->value = val;
var1 = new TNode;
var2 = new TNode;
if(A==(pnew->value=val))
{
var1->value=A;
}
if(B==(pnew->value=val))
{
var2->value=B;
}
var1->value=A;
var1->pnext=*pp;
*pp=var2;
var2->value=B;
var2->pnext=*pp;
*pp=var1;
}
{
TNode **pp = pphead, *pnew, *var1, *var2;
while(*pp)
{
if(val < (*pp)->value)
break;
else
pp = &((*pp)->pnext);
}
pnew = new TNode;
pnew->value = val;
var1 = new TNode;
var2 = new TNode;
if(A==(pnew->value=val))
{
var1->value=A;
}
if(B==(pnew->value=val))
{
var2->value=B;
}
var1->value=A;
var1->pnext=*pp;
*pp=var2;
var2->value=B;
var2->pnext=*pp;
*pp=var1;
}