コード例 #1
0
        public void remove(int value)
        {
            bool isInTheList = false;

            if (start.getInfo() == value)
            {
                if (start.getNext() == null)
                {
                    start       = null;
                    isInTheList = true;
                }
                else
                {
                    NohLista temp = new NohLista();
                    temp = start.getNext();
                    temp.setPrevious(null);
                    start       = temp;
                    isInTheList = true;
                }
            }
            else
            {
                NohLista temp = new NohLista();
                temp = start.getNext();
                for (int i = 0; temp != null; i++)
                {
                    if (temp.getNext() == null && value == end.getInfo())
                    {
                        temp = temp.getPrevious();
                        temp.setNext(null);
                        end         = temp;
                        isInTheList = true;
                        break;
                    }
                    else if (temp.getInfo() == value)
                    {
                        temp.getNext().setPrevious(temp.getPrevious());
                        temp.getPrevious().setNext(temp.getNext());
                        temp        = null;
                        isInTheList = true;
                    }
                    else
                    {
                        temp = temp.getNext();
                    }
                }
            }
            if (!(isInTheList))
            {
                System.Windows.Forms.MessageBox.Show("Digite um número que está presente na lista");
            }
        }
コード例 #2
0
        public int menor()
        {
            int      menor = start.getInfo();
            NohLista temp  = new NohLista();

            temp = start;
            for (int i = 0; temp != null; i++)
            {
                if (temp.getInfo() < menor)
                {
                    menor = temp.getInfo();
                    temp  = temp.getNext();
                }
                else
                {
                    temp = temp.getNext();
                }
            }
            return(menor);
        }
コード例 #3
0
 public void print()
 {
     if (isEmpthy())
     {
         Console.WriteLine("A lista está vazia");
     }
     else
     {
         NohLista temp = new NohLista();
         temp = start;
         for (int i = 1; temp != null; i++)
         {
             Console.WriteLine(i + "°: " + temp.getInfo());
             temp = temp.getNext();
         }
     }
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Scdk/OOP
 private void printlist()
 {
     if (list.isEmpthy())
     {
         tbLista.Text = "";
     }
     else
     {
         string   str  = "";
         NohLista temp = new NohLista();
         temp = list.getStart();
         for (int i = 1; temp != null; i++)
         {
             str += " " + Convert.ToString(temp.getInfo());
             temp = temp.getNext();
         }
         tbLista.Text = str;
     }
 }