Kod: Zaznacz cały
using System;
namespace lista
{
public class ElementListy
{
private ElementListy NowyElement;
public double Wartość;
public ElementListy Następny;
public ElementListy(double x)
{
Wartość = x;
Następny = null;
}
}
private ElementListy Korzeń;
int i;
for(i = 0; i < Tablica.Lenght; i++)
{
if(i == 0)
Korzeń = new ElementListy(Tablica[0]);
}
public ElementListy Nowy;
if(x < Korzeń.Wartość)
{
Nowy = new ElementListy(x);
Następny = Korzeń;
Korzeń = Nowy;
Nowy = null;
}
public class ElementListy
{
public double Wartość;
public ElementListy Następny;
public ElementListy(double x)
{
Wartość = x;
Następny = null;
}
public void DopiszDoListy(double x)
if(this.Wartość < x)
{
if(this.Następny == null)Następny = new ElementListy(x);
else
{
if(Następny.Wartość < x) Następny.DopiszDoListy(x);
else
{
NowyElement = new ElementListy(x);
NowyElement.Następny = this.Następny;
Następny = NowyElement;
NowyElement = null;
} //end if Następny.Wartość < x
}//end if this.Następny == null)
}//end if this.Wartość < x
if(this.Wartość == x)
{
NowyElement = new ElementListy(x);
NowyElement.Następny = this.Następny;
this.Następny = NowyElement;
NowyElement = null;
}