Quick actions

cmd+k|ctrl+k

Navigation

Languages

Kabarcık sıralaması

Snippet info

Language

Csharp

Visibility

public

Author

malihsen

Created

2019-09-16T11:43:42Z

Updated

2019-09-16T11:44:39Z

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kabarcik
{
    class Program
    {
        static void Main(string[] args)
        {
            //Kabarcık Sıralaması
            int[] Array = new int[10] { 7, 70, 14, 77, 15, 17, 87, 19, 33, 99 };
             Console.Write("Sıralama yapılacak dizi ");
            foreach (int x in Array)
          
             Console.Write(x + " ");
            Console.WriteLine();
            int i;
            int j;
            int TempValue;

            for (i = (Array.Length - 1); i >= 0; i--)
            {
                for (j = 1; j <= i; j++)
                {
                    if (Array[j - 1] > Array[j])
                    {
                        TempValue = Array[j - 1];
                        Array[j - 1] = Array[j];
                        Array[j] = TempValue;
                    }
                }
            }

          Console.Write("Sıralanmamış dizi ");
            foreach (int y in Array)
                Console.Write(y + " ");
            Console.ReadKey();
        }
    }
}
INFO