top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Help C# Shell sort .Put in fuction that returns changed array.array int[] is called niz_brojeva

0 votes
357 views

#region shell_sort

          //element for one step of sort
          int elm = 3;

          for (int i = 0; i != niz_brojeva.Length; i++)
          {
              int j = i + elm;

              if (j >= niz_brojeva.Length)
              { j = Convert.ToInt32(niz_brojeva.Length - 1); }

              while (i != j)
              {

                  if (niz_brojeva[i] > niz_brojeva[j])
                  {
                      int temp;
                      temp = niz_brojeva[i];
                      niz_brojeva[i] = niz_brojeva[j];
                      niz_brojeva[j] = temp;          
                  } j--; }
                 }
     #endregion
posted May 6, 2017 by Leon Martinović

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
{ j = Convert.ToInt32(niz_brojeva.Length-1); }
1 up-to-date

...