Другие языки программирования и технологии

С#!!! помогите решить пожалуйста!!!

Напечатать в возрастающем порядке все трехзначные числа, в десятичной записи которых нет одинаковых цифр. Операции деления и взятия остатка от деления не использовать.
Три цикла от 0 до 10 вложенные друг в друга. в самом последнем условие, чтоб индексы циклов не были равны. Если соответсвует умножаем индекс первого цикла на 100, второго на 10 и складываем 3 числа.

Из-за идиотизма правил не могу написать код, т. к он на латинице, отправил в письме
Сергей Полыгалов
Сергей Полыгалов
183
Лучший ответ
class Program
{
static void Main(string[] args)
{
char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

List<string> strings = new List<string>();

IEnumerable<char[]> bases = GetPermutationBases(digits, 3);
foreach (char[] @base in bases)
{
IEnumerable<char[]> permutations = GetPermutations(@base);
foreach (char[] permutation in permutations)
{
if (permutation[0] != '0')
strings.Add(ToString(permutation));
}
}

strings.Sort();
WriteResult(strings);
}

private static void WriteResult(IEnumerable<string> strings)
{
// На консоль
//WriteResult(strings, Console.Out);

// В файл
using (FileStream stream = System.IO.File.Create("output.txt"))
using (StreamWriter writer = new StreamWriter(stream))
WriteResult(strings, writer);
}

private static void WriteResult(IEnumerable<string> strings, TextWriter writer)
{
foreach (string @string in strings)
writer.WriteLine(@string);
}

static string ToString(char[] array)
{
StringBuilder builder = new StringBuilder(array.Length);
foreach (char ch in array)
builder.Append(ch);

return builder.ToString();
}

static IEnumerable< T[] > GetPermutationBases< T >(T[] array, int count)
{
if (count > array.Length)
throw new ArgumentException("Requested count is greater then length of array");

ICollection< T[] > result = new LinkedList< T[] >();

T[] buffer = new T[count];
GetPermutationBases(array, 0, buffer, 0, result);

return result;
}

static void GetPermutationBases< T >(T[] array, int array_index, T[] buffer, int buffer_index, ICollection< T[] > result)
{
if (buffer_index >= buffer.Length)
result.Add((T[]) buffer.Clone());
else
{
for (int i = array_index; i < array.Length; i++)
{
buffer[buffer_index] = array[ i ];
GetPermutationBases(array, i + 1, buffer, buffer_index + 1, result);
}
}
}

static IEnumerable< T[] > GetPermutations< T >(T[] source)
{
ICollection< T[] > result = new LinkedList< T[] >();
GetPermutations(result, source, 0);

return result;
}

static void SwapItems< T >(T[] array, int index1, int index2)
{
T buffer = array[index1];
array[index1] = array[index2];
array[index2] = buffer;
}

static void GetPermutations< T >(ICollection< T[] > result, T[] source, int index)
{
int count = source.Length;

if (index >= count - 1)
result.Add((T[]) source.Clone());
else
{
int next_index = index + 1;
GetPermutations(result, source, next_index);

for (int i = next_index; i < count; i++)
{
SwapItems(source, i, index);
GetPermutations(result, source, next_index);
SwapItems(source, i, index);
}
}
}
}
хорошая задачка =)
препод постарался дать такую чтоб подумали

а что у тебя уже вышло? или ты хочешь чтоб вместо тебя решили и дали готовое решение ?