using System;
public class Program
{
class Node
public int Value { get; set; }
public Node Next { get; set; }
}
static Node head = null;
static Node tail = null;
static void addNode(int val)
Node newNode = new Node();
newNode.Value = val;
if (head == null)
head = newNode;
tail = head;
else
tail.Next = newNode;
tail = newNode;
static void printList()
Node ptr = head;
Console.WriteLine();
while (ptr != null)
Console.Write($" {ptr.Value} ");
static void reverse()
Node prev;
Node curr;
Node next;
prev = null;
curr = head;
while (curr != null)
next = curr.Next;
curr.Next = prev;
prev = curr;
curr = next;
public static void Main()
addNode(1);
addNode(2);
addNode(3);
addNode(4);
addNode(5);