.NET 4.x Все возможные комбинации - C#
Формулировка задачи:
Как вывести построчно все возможные комбинации, нижний, верхний регистр и цифры, Длинна :18 знаков.
Решение задачи: «.NET 4.x Все возможные комбинации»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Console.Write("Введите искомую комбинацию: "); //вводим например aaaaaaaaaaaaaf2a
string combotofind = Console.ReadLine();
var query = from a in alphabet
from b in alphabet
from c in alphabet
from d in alphabet
from e in alphabet
from f in alphabet
from g in alphabet
from h in alphabet
from i in alphabet
from j in alphabet
from k in alphabet
from l in alphabet
from m in alphabet
from n in alphabet
from o in alphabet
from p in alphabet
select "" + a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p;
foreach (var item in query)
{
if (item == combotofind) { Console.WriteLine(item + " - Комбинация найдена, процесс остановлен!"); break; }
else Console.WriteLine(item);
}
Console.ReadKey();
}
}
}