Új hozzászólás Aktív témák

  • pmonitor

    aktív tag

    válasz joysefke #9468 üzenetére

    Én így fordítottam át:
    using System;

    namespace IsmPerm
    {
    class Program
    {
    static int findCeilInt(int[] str, int first, int l, int h)
    {
    int ceilIndex = l;
    for (int i = l + 1; i <= h; i++)
    if (str[i] > first && str[i] < str[ceilIndex])
    ceilIndex = i;
    return ceilIndex;
    }

    static void Teszt_1(int[] tomb)
    { //https://www.geeksforgeeks.org/print-all-permutations-of-a-string-with-duplicates-allowed-in-input-string/
    int size = tomb.Length;
    Array.Sort(tomb);
    bool isFinished = false;
    while (!isFinished)
    {
    int x = 1, i;

    for (int k = 0; k < size; ++k) Console.Write("{0} ", tomb[k]);
    Console.WriteLine("");

    for (i = size - 2; i >= 0; --i) if (tomb[i] < tomb[i + 1]) break;
    if (i == -1) isFinished = true;
    else
    {
    int ceilIndex = findCeilInt(tomb, tomb[i], i + 1, size - 1);
    int temp = tomb[i];
    tomb[i] = tomb[ceilIndex];
    tomb[ceilIndex] = temp;
    Array.Sort(tomb, i + 1, size - i - 1);
    }
    }
    }

    static void Main(string[] args)
    {
    int[] tomb = new int[] { 500, 500, 600, 600, 700};
    Teszt_1(tomb);
    Console.ReadKey();
    }
    }
    }

    http://www.bferi.hu/download.php ; http://bferi.hu/egyeb.php

Új hozzászólás Aktív témák