Advertisement
ntamas

Rendezés másképp

Feb 27th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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[] tomb = new int[] { 49, 28, 44, 6, 32, 29, 6, 44, 4, 40, 29, 17, 48, 9};
  13.       List<int> lista = new List<int>();
  14.       List<int> eredmeny = new List<int>();
  15.       lista = tomb.ToList();
  16.       int minindex = 0;
  17.       do
  18.       {
  19.         minindex = lista.IndexOf(lista.Min());
  20.         eredmeny.Add(lista[minindex]);
  21.         lista.RemoveAt(minindex);
  22.       }while(eredmeny.Count < tomb.Length);
  23.       for (int i = 0; i < tomb.Length; i++)
  24.       {
  25.         Console.Write("{0, 3} ", tomb[i]);
  26.       }
  27.       Console.WriteLine();
  28.       for (int i = 0; i < eredmeny.Count; i++)
  29.       {
  30.         Console.Write("{0, 3} ", eredmeny[i]);
  31.       }
  32.       /*Console.WriteLine();
  33.       lista = tomb.ToList();
  34.       lista.Sort();
  35.       for (int i = 0; i < lista.Count; i++)
  36.       {
  37.         Console.Write("{0} ", lista[i]);
  38.       }*/
  39.       Console.ReadKey();
  40.     }
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement