using System; using System.Collections.Generic; using System.Linq; class Massiivitehted4{ public static void Main(string[] arg) { int[] m = { 2, 6, 4, 5, 3, 2 }; Console.WriteLine("Neljast suuremaid: " + m.Count(a => a > 4)); Console.WriteLine("Neljast suuremad: "+ string.Join(" ", m.Where(a => a > 4))); Console.WriteLine("Esimene neist: " + m.First(a => a > 4)); Console.WriteLine("Kahega korrutatult: " + string.Join(" ", m.Select(a => a * 2))); IEnumerable baidid=m.Select(a=>(a*2)+"x"); IEnumerable massiivid=m.Select(a=>new int[a]); IEnumerable massiivid2=m.SelectMany(a=>new int[a]); Console.WriteLine("Nullihunnik: " + string.Join(" ", massiivid2)); Console.WriteLine("Nullihunnik: " + string.Join(" ", massiivid2.Concat(m))); Console.WriteLine("Kahega korrutatult: " + string.Join(" ", m.Select(a => (a * 2)+"b"))); Console.WriteLine("Kuni väärtuseni 5: " + string.Join(" ", m.TakeWhile(a => a != 5))); Console.WriteLine("Alates väärtusest 5: " + string.Join(" ", m.SkipWhile(a => a != 5))); Console.WriteLine("Kahanevalt sorditult "+ string.Join(" ",m.OrderBy(a => -a))); } }