Last active
May 19, 2021 20:09
-
-
Save Vovanda/51018532c75ce4ef4d84340dc5d7e42b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
var rnd = new Random(Guid.NewGuid().GetHashCode()); | |
Func<int, bool> predicat = x => x > 3; | |
var arr = new[] {1, 3, 7, 4, 5}; | |
var check = new bool[arr.Length]; | |
int count = arr.Length; | |
while(count > 0) | |
{ | |
int index = rnd.Next(arr.Length); | |
if(!check[index]) | |
{ | |
if(predicat(arr[index])) | |
{ | |
Console.WriteLine(arr[index]); | |
} | |
count--; | |
check[index] = true; | |
} | |
} | |
Console.WriteLine("Done!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 | |
4 | |
7 | |
Done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": 1, | |
"target": "Run", | |
"mode": "Debug" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment