Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
stack using LinkedList in C#
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Node { public int Value {get; set;} public Node Next {get; set;} } public class Stack { Node head; //print stack elements public void PrintAllNodes() { Node current = head; while(current!=null){ Console.WriteLine(current.Value); current=current.Next; } } //push operation public void Push(Object Val) { Node temp= new Node(); temp.Value =(int) Val; temp.Next=head; head=temp; } //pop operation public void Pop() { Node temp= new Node(); if( head==null) {Console.Write("Head is null");} temp= head; head= head.Next; temp=null; } } public class Program{ public static void Main(string[] args) { Stack st= new Stack(); Node h = new Node(); st.Push(3); st.Push(8); st.Push(5); Console.Write("after push \n"); st.PrintAllNodes(); st.Pop(); Console.Write("after POP \n"); st.PrintAllNodes(); } }}
run
|
edit
|
history
|
help
0
toplam
asxsadaxsdf
test
True and false
aba
Given a list of numbers and a number k, return whether any two numbers from the list add up to k
2.10.4
insertion sort
max & min binary search tree
Math 11.0 Finished fracOp