• //11-masala: Massivni qoshish
  • //13-masala: Massivni toldirish int[] numbers = new int[5]; numbers.Fill(10); //14-masala: Massivni filtrlash
  • //16-masala: Massivni kamaytirish
  • //18-masala: Massivni tartiblash (maxsus tartiblash) int[] numbers = { 10, 20, 30, 40, 50 }; Array.Sort(numbers, (a, b) => b - a); //19-masala: Massivni guruhlash
  • //20-masala: Massivni birlashtirish
  • //9-masala: Massivdan ma'lum bir elementni o'chirish




    Download 22,12 Kb.
    bet3/4
    Sana14.05.2024
    Hajmi22,12 Kb.
    #232468
    1   2   3   4
    Bog'liq
    DASTURIY INJENERING (2)

    //9-masala: Massivdan ma'lum bir elementni o'chirish
    int[] numbers = { 10, 20, 30, 40, 50 };
    int indexToRemove = 2;
    Array.Clear(numbers, indexToRemove, 1);

    //10-masala: Massivni ikkita massivga bo'lish
    int[] numbers = { 10, 20, 30, 40, 50 };
    int mid = numbers.Length / 2;
    int[] firstHalf = numbers.Take(mid).ToArray();
    int[] secondHalf = numbers.Skip(mid).ToArray();

    //11-masala: Massivni qo'shish
    int[] numbers1 = { 10, 20, 30 };
    int[] numbers2 = { 40, 50, 60 };
    int[] combined = numbers1.Concat(numbers2).ToArray();

    //12-masala: Massivni ajratish
    int[] numbers = { 10, 20, 30, 40, 50, 60 };
    int chunkSize = 2;
    var chunks = numbers.Chunk(chunkSize);

    //13-masala: Massivni to'ldirish
    int[] numbers = new int[5];
    numbers.Fill(10);

    //14-masala: Massivni filtrlash
    int[] numbers = { 10, 20, 30, 40, 50 };
    int[] filtered = numbers.Where(n => n % 2 == 0).ToArray();

    //15-masala: Massivni proyeksiyalash
    int[] numbers = { 10, 20, 30, 40, 50 };
    string[] projected = numbers.Select(n => n.ToString()).ToArray();

    //16-masala: Massivni kamaytirish
    int[] numbers = { 10, 20, 30, 40, 50 };
    int total = numbers.Aggregate((a, b) => a + b);

    //17-masala: Massivda dublikatlarni olib tashlash
    int[] numbers = { 10, 20, 30, 40, 50, 10, 20 };
    int[] distinct = numbers.Distinct().ToArray();

    //18-masala: Massivni tartiblash (maxsus tartiblash)
    int[] numbers = { 10, 20, 30, 40, 50 };
    Array.Sort(numbers, (a, b) => b - a);

    //19-masala: Massivni guruhlash
    int[] numbers = { 10, 20, 30, 40, 50, 60 };
    var grouped = numbers.GroupBy(n => n % 2);

    //20-masala: Massivni birlashtirish
    int[] numbers1 = { 10, 20, 30 };
    int[] numbers2 = { 40, 50, 60 };
    int[] merged = numbers1.Union(numbers2).ToArray();


    Download 22,12 Kb.
    1   2   3   4




    Download 22,12 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    //9-masala: Massivdan ma'lum bir elementni o'chirish

    Download 22,12 Kb.