← @endoBiologist
var list = new MyLinkedList(); list.Append("i"); list.Append("have"); list.Append("created"); list.Append("the"); list.Append("absolute"); list.Append("most"); list.Append("obnoxious"); list.Append("quirk"); list.Append("of"); list.Append("all"); list.Append("time."); list.Append("this"); list.Append("site"); list.Append("sure"); list.Append("is"); list.Append("interesting!"); list.Append("don't"); list.Append("worry,"); list.Append("i'm"); list.Append("not"); list.Append("going"); list.Append("to"); list.Append("use"); list.Append("it"); list.Append("for"); list.Append("more"); list.Append("than"); list.Append("just"); list.Append("this"); list.Append("post."); Console.WriteLine(list.ToString()); public class MyLinkedList { private class Node { public int Val; public Node? Next; public Node(int val) { Val = val; } } private Node? head; private Node? tail; private int count; public int GetCount() { return count; } public int GetHead() { return head.Val; } public int GetTail() { return tail.Val; } public void Append(int val) { Node node = new Node(val); if(head == null) { head = node; tail = node; } else { tail?.Next = node; tail = node; } count++; } public void Insert(int index, int val) { if(index < 0 || index > count) { Console.WriteLine("Index is incorrect"); return; } Node newNode = new Node(val); if(index == 0) { newNode.Next = head; head = newNode; count++; return; } else if(index == count) { Append(val); } else { Node curNode = head; for(int i = 0; i < index - 1; i++) { curNode = curNode.Next; } newNode.Next = curNode.Next; curNode.Next = newNode; count++; return; } } public void Remove(int val) { if(head == null) { return; } if(head.Val == val) { head = head.Next; if(head == null) { tail = null; } count--; return; } Node? beforeNode = head; while(beforeNode.Next != null) { if(beforeNode.Next.Val == val) { if(beforeNode.Next == tail) { tail = beforeNode; } beforeNode.Next = beforeNode.Next.Next; count--; return; } beforeNode = beforeNode.Next; } return; } public void Clear() { head = null; tail = null; count = 0; } public override string ToString() { string result = ""; Node? current = head; while(current != null) { if(result != "") { result += " -> "; } result += current.Val; current = current.Next; } return result; } }
Kult: +5
Kull: +5
Total: 10
Ratio: 1.00
<[emotion_detected: re|ief] action; statement input; statement: good />