Advertisement
GraionDilach

Alfüggvényes rendezés

Feb 21st, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int[] DasArray = new int[20];
  13.             Random RandNum = new Random();
  14.  
  15.             for (int i = 0; i < DasArray.Length; i++)
  16.             {
  17.                 DasArray[i]= RandNum.Next(10,50);
  18.                 Console.Write(DasArray[i] + " ");
  19.             }
  20.             Console.WriteLine();
  21.             Ordering(DasArray);
  22.  
  23.             for (int i = 0; i < DasArray.Length; i++)
  24.             {
  25.                 Console.Write(DasArray[i] + " ");
  26.             }
  27.         }
  28.        
  29.         static void Ordering(int[] Input)
  30.         {
  31.             for (int i = 1; i < Input.Length; i++)
  32.             {
  33.                 for (int j = 0; j < Input.Length - i; j++)
  34.                 {
  35.                     if (Input[j] > Input[j + 1])
  36.                     {
  37.                         int Temp = Input[j];
  38.                         Input[j] = Input[j + 1];
  39.                         Input[j + 1] = Temp;
  40.                     }
  41.                 }
  42.             }
  43.  
  44.         }
  45.  
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement