To issue a task to an array using lamda expressions. Elements of an array obtained using Random. An array of size N is given. Reverse the order of its elements.
- An array of size N is given. Reverse the order of its elements. - cat
- to reverse the order using lambda? the task is not very clear. - Specter
|
1 answer
At the moment, I see the solution like this:
void Main() { Random rand = new Random(); var a = Enumerable.Range(1,10).Select(el=>rand.Next(1,10)).Reverse(); //[6,6,2,2,9,3,4,1,5,7] примерно так } Enumerable.Range(1,10)- creates a set of ten numbers starting from oneSelect(el=>rand.Next(1,10))- creates random numbers and selects themReverse()- reverses their order
|