Using System; using System. Linq; class Program { static void Main { int[] a = { , 8, 12, 3, 7, 9, 2, 4, }; var oddElements = a. Where(x => x != 0). OrderBy(x => x). Select(x=>x); foreach


Download 130.51 Kb.
Sana03.04.2023
Hajmi130.51 Kb.
#1322144
Bog'liq
1-9


1-misol
Butun turdagi a massiv berilgan. Massivning toq elementlarini o'sish tartibida chop qiling.
using System;
using System.Linq;

class Program {
static void Main() {
int[] a = { 1, 8, 12, 3, 7, 9, 2, 4, 5 };
var oddElements = a.Where(x => x % 2 != 0).OrderBy(x => x).Select(x=>x);
foreach (var element in oddElements)
{
Console.WriteLine(element);
}
}
}
Javobi: 1
3
5
7
9


9-misol:
Satr turdagi massiv berilgan.Massivning elementlari "A" harfidan boshlangan elementlarini toping.
using System;
using System.Linq;

class Program {
static void Main() {
string[] array = { "Apple", "Ball", "Air", "Cat", "Ant", "Eat", "Fan", "Atom" };
var startsWithA = array.Where(str => str.StartsWith("A")).Select(str => str);
foreach (var word in startsWithA)
{
Console.WriteLine(word);
}
}
}Javobi:
Apple
Air
Ant
Atom

Download 130.51 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling