Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
circular linked list
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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 { class Circularlist { private int currentdata; private Circularlist nextdata; public Circularlist() { currentdata = 0; nextdata = this; } public Circularlist(int value) { currentdata = value; nextdata = this; } public Circularlist Insdata(int value) { Circularlist node = new Circularlist(value); if (this.nextdata == this) { node.nextdata = this; this.nextdata = node; } else { Circularlist temp = this.nextdata; node.nextdata = temp; this.nextdata = node; } return node; } public int Deldata() { if (this.nextdata == this) { System.Console.WriteLine("\nOnly one node..."); return 0; } Circularlist node = this.nextdata; this.nextdata = this.nextdata.nextdata; node = null; return 1; } public void Traverse() { Traverse(this); } public void Traverse(Circularlist node) { if (node == null) node = this; System.Console.WriteLine("Forward Direction..."); Circularlist snode = node; do { System.Console.WriteLine(node.currentdata); node = node.nextdata; } while (node != snode); } public int Gnodes() { return Gnodes(this); } public int Gnodes(Circularlist node) { if (node == null) node = this; int count = 0; Circularlist snode = node; do { count++; node = node.nextdata; } while (node != snode); System.Console.WriteLine("\nCurrent Node Value : " + node.currentdata.ToString()); System.Console.WriteLine("\nTotal nodes :" + count.ToString()); return count; } public class Program { public static void Main(string[] args) { Circularlist node1 = new Circularlist(100); node1.Deldata(); Circularlist node2 = node1.Insdata(200); node1.Deldata(); node2 = node1.Insdata(200); Circularlist node3 = node2.Insdata(300); Circularlist node4 = node3.Insdata(400); Circularlist node5 = node4.Insdata(500); node1.Gnodes(); node3.Gnodes(); node5.Gnodes(); node1.Traverse(); node5.Deldata(); node2.Traverse(); node1.Gnodes(); node2.Gnodes(); node5.Gnodes(); Console.Read(); } } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0,14 sec, absolute running time: 0,09 sec, cpu time: 0,11 sec, average memory usage: 15 Mb, average nr of threads: 3, absolute service time: 0,24 sec
edit mode
|
history
|
discussion
Error(s):
Entry method 'Main' in class 'Program' in namespace 'Rextester' not found.