public static void AddNodeA(IntNode a, int x) { bool flag = true; while (a.GetNext() != null) { if (x > a.GetInfo() && x <= a.GetNext().GetInfo()) { IntNode c = new IntNode(x, a.GetNext()); a.SetNext(c); a = c; flag = false; } else if (x <= a.GetInfo() && flag) { IntNode c = new IntNode(a.GetInfo(), a.GetNext()); a.SetInfo(x); a.SetNext(c); flag = false; } a = a.GetNext(); } if (x > a.GetInfo() && flag) { IntNode p = new IntNode(x); a.SetNext(p); } }